MsgWaitForMultipleObjects 返回拒绝访问
我有以下创建进程的函数:
function .CreateProcess(aAppletPath: string; var aError : string; aProcessInfo: TProcessInformation): Boolean;
var
StartInfo: TStartupInfo;
begin
FillChar(StartInfo, SizeOf(TStartupInfo),#0);
FillChar(aProcessInfo, SizeOf(TProcessInformation),#0);
StartInfo.cb := SizeOf(TStartupInfo);
if False then begin
StartInfo.dwFlags := STARTF_USESHOWWINDOW;
StartInfo.wShowWindow := SW_HIDE;
end;
if Windows.CreateProcess(nil, PChar(aAppletPath), nil, nil, False, CREATE_NEW_PROCESS_GROUP + NORMAL_PRIORITY_CLASS, nil, nil, StartInfo, aProcessInfo) then begin
Result := True;
WaitForInputIdle(aProcessInfo.hProcess, oTimeOutSecs * 1000);
end
else begin
Result := False;
end;
end;
我有这个等待应用程序终止的方法:
function WaitForProcessTerminate(aHandle: THandle) : Boolean;
var
vResult : LongWord;
Msg: TMsg;
PHandles: Pointer;
begin
vResult := 0;
PHandles := @aHandle;
PeekMessage(Msg, 0, 0, 0, PM_NOREMOVE);
while True do begin
vResult := Windows.MsgWaitForMultipleObjects(1, PHandles^, False, oTimeOutSecs * 1000, QS_ALLINPUT);
if vResult = WAIT_OBJECT_0 + 1 then begin
if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end
else begin
Break;
end;
end;
case vResult of
WAIT_ABANDONED: Result := False;
WAIT_OBJECT_0: Result := True;
WAIT_TIMEOUT: Result := False;
else begin
Result := False;
end;
end;
if not Result then begin
ShowMessage(SystemErrorMessage);
end;
end;
问题是等待函数总是返回 WAIT_FAILED
并带有 访问被拒绝
信息。我做错了什么?这段代码是Delphi 2010,我调用的应用程序是一个java应用程序。
I have the follow function that creates a process:
function .CreateProcess(aAppletPath: string; var aError : string; aProcessInfo: TProcessInformation): Boolean;
var
StartInfo: TStartupInfo;
begin
FillChar(StartInfo, SizeOf(TStartupInfo),#0);
FillChar(aProcessInfo, SizeOf(TProcessInformation),#0);
StartInfo.cb := SizeOf(TStartupInfo);
if False then begin
StartInfo.dwFlags := STARTF_USESHOWWINDOW;
StartInfo.wShowWindow := SW_HIDE;
end;
if Windows.CreateProcess(nil, PChar(aAppletPath), nil, nil, False, CREATE_NEW_PROCESS_GROUP + NORMAL_PRIORITY_CLASS, nil, nil, StartInfo, aProcessInfo) then begin
Result := True;
WaitForInputIdle(aProcessInfo.hProcess, oTimeOutSecs * 1000);
end
else begin
Result := False;
end;
end;
And I have this method that waits the app terminates:
function WaitForProcessTerminate(aHandle: THandle) : Boolean;
var
vResult : LongWord;
Msg: TMsg;
PHandles: Pointer;
begin
vResult := 0;
PHandles := @aHandle;
PeekMessage(Msg, 0, 0, 0, PM_NOREMOVE);
while True do begin
vResult := Windows.MsgWaitForMultipleObjects(1, PHandles^, False, oTimeOutSecs * 1000, QS_ALLINPUT);
if vResult = WAIT_OBJECT_0 + 1 then begin
if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end
else begin
Break;
end;
end;
case vResult of
WAIT_ABANDONED: Result := False;
WAIT_OBJECT_0: Result := True;
WAIT_TIMEOUT: Result := False;
else begin
Result := False;
end;
end;
if not Result then begin
ShowMessage(SystemErrorMessage);
end;
end;
The problem is that the wait function is always returning WAIT_FAILED
with the Access denied
message. What am I doing wrong? This code is Delphi 2010 and the app i am calling is a java app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系,伙计们。这是我的错误。功能:
应该是:
抱歉。
Nevermind guys. It was my mistake. The function:
should be:
My apologies.