shellexecute的问题(30分)

一成

Unregistered / Unconfirmed
GUEST, unregistred user!
var<br>&nbsp; &nbsp;h:integer;<br>h:=ShellExecute(handle,nil,Pchar('c:/888.exe'),nil,nil,1);<br><br>这里的“h”的值到底是什么?跟c:/888.exe有什么关系?<br>通过‘h’可不可以对此打开的程序进行操作,比如关闭或隐藏此程序
 
有啊,就是888的句并啊!
 
看ShellExecute的帮助
 
h是process句柄,可以用TerminateProcess来关闭这个程序<br>要隐藏的话得用fIndWindow<br><br>-----<br>http://www.8421.org
 
to qdyoung<br>&nbsp; 能给出关闭、隐藏、调到当前的代码吗?<br><br>为何我用showwindow(h,sw_hide)无法隐藏此打开窗口?
 
showwindow(h,sw_hide)只对程序的句柄进行了操作,而不是程序中的窗口句柄,当然没有<br>效果。<br><br>用CreateProcess函数和TerminateProcess函数可以启动和关闭进程。
 
终止:<br>if TerminateProcess(h, 0) then <br>&nbsp; showMessage('ok');<br><br>隐藏、显示<br>&nbsp; hwin := FindWindow('TheMainClassName', 'TheMainWindowCaption');<br><br>&nbsp; if hwin &gt; 0 then<br>&nbsp; &nbsp; ShowWindow(hwin, SW_Hide);<br><br>&nbsp; if hwin &gt; 0 then<br>&nbsp; &nbsp; ShowWindow(hwin, SW_Show); <br><br>那个程序的'TheMainClassName', 'TheMainWindowCaption'<br>即主窗口类名和标题都可以通过winsight看到
 
是 实例句柄。相当于hinstance.<br>如果你要关闭888.exe,可以exitprocess(h);
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
955
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
顶部