S
saving
Unregistered / Unconfirmed
GUEST, unregistred user!
如何执行外部程序[并一直等到它结束] ?
我在网上找到2个程序代码:
var
sCommandLine: string;
bCreateProcess: boolean;
lpStartupInfo: TStartupInfo;
lpProcessInformation: TProcessInformation;
begin
sCommandLine := 'ARJ.EXE /?';
bCreateProcess := CreateProcessA(nil, PChar(sCommandLine),
nil, nil, True, NORMAL_PRIORITY_CLASS, nil, nil,
lpStartupInfo, lpProcessInformation);
if bCreateProcess then
WaitForSingleObject(lpProcessInformation.hProcess, INFINITE);
end;
//////////////////////////////////////////////
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;
第一个:编译通过,运行无反应,不能调出其他程序,不管是DOS程序还是win98下的程序。
第二个:GetModuleUsage未定义,编译通不过。
请指教!
我在网上找到2个程序代码:
var
sCommandLine: string;
bCreateProcess: boolean;
lpStartupInfo: TStartupInfo;
lpProcessInformation: TProcessInformation;
begin
sCommandLine := 'ARJ.EXE /?';
bCreateProcess := CreateProcessA(nil, PChar(sCommandLine),
nil, nil, True, NORMAL_PRIORITY_CLASS, nil, nil,
lpStartupInfo, lpProcessInformation);
if bCreateProcess then
WaitForSingleObject(lpProcessInformation.hProcess, INFINITE);
end;
//////////////////////////////////////////////
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;
第一个:编译通过,运行无反应,不能调出其他程序,不管是DOS程序还是win98下的程序。
第二个:GetModuleUsage未定义,编译通不过。
请指教!