有关进程句柄的疑问??(10分)

  • 主题发起人 主题发起人 AKang
  • 开始时间 开始时间
A

AKang

Unregistered / Unconfirmed
GUEST, unregistred user!
程序段如下:<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; myHwnd:THandle;<br>&nbsp; ProID:^Integer;<br>&nbsp; myHandle:THandle;<br>begin<br>&nbsp; myHwnd:=FindWindow(Nil,'Age of Empires II');<br>&nbsp; //得到窗口句柄<br>&nbsp; //showmessage(format('%x',[myHwnd]));<br>&nbsp; New(ProID);<br>&nbsp; GetWindowThreadProcessID(MyHwnd,ProID);<br>&nbsp; //得到进程ID<br>&nbsp; //ShowMessage(format('%x',[ProID^]));<br>&nbsp; myHandle:=OpenProcess(Process_All_Access,false,ProID^);<br>&nbsp; //得到进程句柄<br>&nbsp; //SHowMessage(Format('%x',[myHandle]));<br>&nbsp; if myHandle=$24 then<br>&nbsp; TerminateProcess(myHandle,0);<br>end;<br>疑问如下:<br>1.不管我找的是哪个程序,得到的myHandle都等于$1C,但如果再按一下Button1,就会加$4,再按再加<br>2.但是不管我在myHandle等于任何值,用TerminateProcess都可关闭它。<br><br>请各位高手赐教。<br><br>
 
好象应该:<br>myHandle:=OpenProcess(PROCESS_TERMINATE,false,ProID^);
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
I
回复
0
查看
585
import
I
后退
顶部