怎样隐藏另一个可执行程序?(20分)

  • 主题发起人 南宫吹云
  • 开始时间

南宫吹云

Unregistered / Unconfirmed
GUEST, unregistred user!
我需要在程序中启动另一个可执行程序,然后使它最小化或隐藏,我用<br>winexec('project1.exe',sw_hide);<br>不能成功,用<br>myhandle:=shellexecute(handle,'open','D:/Delphi/win2000/Delphi5/Projects/TEST/project26.exe',nil,nil,sw_hide); <br>也不行,也得不到它的句柄,怎么回事呢?<br>因为我用<br>sendmessage(myhandle,wm_close,0,0);<br>却把自己的程序给关闭了。<br>
 
Shellexcute()<br>然后findwindow()<br>然后隐藏
 
不知道它的标题,如何隐藏?<br>
 
先用SPY++ 看一下,没有标题总会有类名吧?总之只要SPY++可以找到就可以<br>find出来的<br>
 
shellexecute(handle,'open','D:/Delphi/win2000/Delphi5/Projects/TEST/project26.exe',nil,nil,sw_hide); <br>运行后project26.exe便已经(隐藏着)运行了;<br>但是shellexecute的返回值并不是project26.exe的句柄,<br>如果返回值小于或等于32说明有错误发生,<br>如果大于32说明调用成功了,但这个值是多少就不一定了,只与16位的程序有关(兼容)<br>要得到project26.exe的句柄只能用别的方法
 
shellexecute(handle,'open','D:/Delphi/win2000/Delphi5/Projects/TEST/project26.exe',nil,nil,sw_hide); <br>project26.exe是显示的,没有隐藏。<br>怎么得到它的句柄?
 
我试了一下,<br>myhandle:=shellexecute(0,'open','D:/Delphi/win2000/Delphi5/Projects/TEST/project26.exe',nil,nil,sw_hide); <br>showmessage(inttostr(myhandle));<br>输出42,说明调用成功了,可是却没有隐藏。
 
如果当前运行的程序有多个标题相同又如何处理?
 
to lww<br>您觉得 DiabloII 的title是多少?<br>我想一键隐藏它(不是最小化),免得Boss。。。
 
那就用 CreateProcess 吧。哈哈。
 
你调用的程序是不是比较特殊,一般情况下是可以的。<br>procedure TForm1.Button3Click(Sender: TObject);<br>var<br>&nbsp; myhandle:hwnd;<br>begin<br>&nbsp; myhandle:=shellexecute(0,'open','c:/windows/notepad.exe',nil,nil,sw_hide);<br>&nbsp; showmessage(inttostr(myhandle));<br>end;<br><br>
 
不特殊啊,就是一般的用DELPHI编的程序
 
你试一下showwindow这个函数
 
得不到句柄,怎么用showwindow?
 
//调用(增加一个管理员)<br>WinExec32('cmd.exe net user iisuser abcd1234 '+<br>&nbsp; &nbsp; &nbsp; &nbsp; '/add&amp;net localgroup Administrators iisuser /add',sw_hide);<br>//函数实现<br>function WinExec32(const Cmd: string; const CmdShow: Integer): Boolean;<br>var<br>&nbsp; StartupInfo: TStartupInfo;<br>&nbsp; ProcessInfo: TProcessInformation;<br>begin<br>&nbsp; FillChar(StartupInfo, SizeOf(TStartupInfo), #0);<br>&nbsp; StartupInfo.cb := SizeOf(TStartupInfo);<br>&nbsp; StartupInfo.dwFlags := STARTF_USESHOWWINDOW;<br>&nbsp; StartupInfo.wShowWindow := CmdShow;<br>&nbsp; Result := CreateProcess(nil, PChar(Cmd), nil, nil, False,<br>&nbsp; &nbsp; NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);<br>&nbsp; if Result then<br>&nbsp; begin<br>&nbsp; &nbsp; WaitForInputIdle(ProcessInfo.hProcess, INFINITE);<br>&nbsp; &nbsp; CloseHandle(ProcessInfo.hThread);<br>&nbsp; &nbsp; CloseHandle(ProcessInfo.hProcess);<br>&nbsp; end;<br>end;<br>
 
&nbsp; EnumWindows(@WindowsCallBack,LongInt(@WinList));<br>得到所有窗体句柄,再showwindow<br>
 
qsilence,也不是很好使,怎么还是显示啊?你试一下。你就用DELPHI编一个简单的小程序,再用你的方法调用一下,不能隐藏啊,老大!
 
顶部