我用createprocess函数,成功打开了外部程序,现在我如何找到该程序的主窗体和句柄..
var
i: Boolean;
PI: _PROCESS_INFORMATION;
SI: _STARTUPINFOA;
begin
fillchar(SI, sizeof(SI), 0);
SI.cb := sizeof(SI);
SI.wShowWindow := SW_HIDE;
//SI.dwFlags := STARTF_USESHOWWINDOW;
i := CreateProcess(nil, PChar('notepad.exe'), nil, nil, FALSE, CREATE_DEFAULT_ERROR_MODE, nil, nil, SI, PI);
if i = TRUE then showmessage('right');
//测试
l3.Caption := inttostr(PI.hProcess) + '=====' + inttostr(PI.hThread);
end;
var
i: Boolean;
PI: _PROCESS_INFORMATION;
SI: _STARTUPINFOA;
begin
fillchar(SI, sizeof(SI), 0);
SI.cb := sizeof(SI);
SI.wShowWindow := SW_HIDE;
//SI.dwFlags := STARTF_USESHOWWINDOW;
i := CreateProcess(nil, PChar('notepad.exe'), nil, nil, FALSE, CREATE_DEFAULT_ERROR_MODE, nil, nil, SI, PI);
if i = TRUE then showmessage('right');
//测试
l3.Caption := inttostr(PI.hProcess) + '=====' + inttostr(PI.hThread);
end;
begin
TMemo(lParam).Lines.Add(IntToStr(hwnd));
Result := False;
end;procedure TForm1.Button1Click(Sender: TObject);
var
PI: _PROCESS_INFORMATION;
SI: _STARTUPINFOA;
begin
fillchar(SI, sizeof(SI), 0);
SI.cb := sizeof(SI);
SI.wShowWindow := SW_HIDE;
if not CreateProcess(nil, 'notepad.exe', nil, nil, False,
CREATE_DEFAULT_ERROR_MODE, nil, nil, SI, PI) then Exit;
Sleep(500); //延迟
EnumThreadWindows(PI.dwThreadId, @EnumThreadWndProc, Integer(Memo1));
end;
SI.wShowWindow := SW_HIDE;
SI.dwFlags := STARTF_USESHOWWINDOW;
i := CreateProcess(nil, PChar('notepad.exe'), nil, nil, FALSE,CREATE_DEFAULT_ERROR_MODE, nil, nil, SI, PI);如果我打开的是 notepad.exe ,则窗体自动隐藏,如果我打开的是其它的程序,毕如 regedit.exe,则不能隐患窗体,请问如何解决..