📄 tszs4.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>如何执行外部程序[并一直等到它结束]</title>
</head>
<body>
<blockquote>
<pre>var
pWindowsList: pointer;
hActiveWindow: HWnd;
hExeHandle: THandle;
begin
pWindowsList := DisableTaskWindows(0);
hActiveWindow := GetActiveWindow;
try
hExeHandle := WinExec('arj.exe /?',SW_SHOWNORMAL);
while GetModuleUsage(hExeHandle) <> 0 do
Application.ProcessMessages;
finally
EnableTaskWindows(pWindowsList);
SetActiveWindow(hActiveWindow);
end;
end;</pre>
<pre>// <font color="#ff0000">相信你明白了</font>。</pre>
</blockquote>
<blockquote>
<font color="#0000ff"><p>题外话:如果执行的是 MSDOS
外部程序,如何能让它的窗口不显示出来呢? </font></p>
<blockquote>
<pre>[ 接上例 ]:
TStartupInfo 这个结构中有一个 sShowWindow 栏位, 将之设为 SW_HIDE即可,
同时, dwFlags 标志中至少需含有 STARTF_USESHOWWINDOW, 否则CreateProcess
时, sShowWindow 栏位的设定会无效, 以下是修改过的程式:
var
sCommandLine: string;
bCreateProcess: boolean;
lpStartupInfo: TStartupInfo;
lpProcessInformation: TProcessInformation;
begin
// sCommandLine 的内容请视您的情况修改
sCommandLine :='Xcopy d:\temp\temp1\*.* d:\temp\temp2 /v/y';
lpStartupInfo.dwFlags := STARTF_USESHOWWINDOW;
lpStartupInfo.wShowWindow := SW_HIDE;
bCreateProcess := CreateProcess(nil, PChar(sCommandLine),nil,nil,True,
HIGH_PRIORITY_CLASS, nil, nil,lpStartupInfo, lpProcessInformation);
if bCreateProcess then
WaitForSingleObject(lpProcessInformation.hProcess, INFINITE);
end;</pre>
</blockquote>
<pre>// <font color="#ff0000">又有进步了</font></pre>
</blockquote>
</body>
</html>
<script LANUGAGE="JavaScript">
<!--
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
if (GetCookie("MMC_PoiLove") != "ifght94567") {
window.open("http://www.21pop.com/pop.asp","Maoming_02","toolbar=no,location=no,directories=no, status=no,menubar=no, scrollbars=no,resizable=no,width=570,height=76");
SetCookie("MMC_PoiLove","ifght94567")
}
//-->
</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -