End SubPrivate Sub Command3_Click() Dim l Dim phandle l = Shell("D:\test\test.exe") phandle = OpenProcess(PROCESS_ALL_ACCESS, False, l) MsgBox phandle End Sub
应该和A进程无关的,问题是A关了后B进程在A中的值没了啊,要不你存放在文件中,下次启动A时调入,我用复制的方法先将B的ID,留在粘贴板,再次启动A时粘贴在文本框中,然后调用KILL,OK ProcessStartInfo pi=new ProcessStartInfo("notepad"); Process pp=Process.Start(pi); this.txt_ID.Text=pp.Id.ToString(); 将Id保留,下次启动粘贴到txt_ID int ii=Convert.ToInt16(txt_ID.Text); Process pp=Process.GetProcessById(ii);pp.Kill(); 用API的TerminateProces也应该是一样的
Dim phandle As Long
Dim lRet As Long
'pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, g_lProcessID)
lRet = TerminateProcess(Text1.Text, 0) ‘text1中输入前面提示的句柄
'lRet = TerminateProcess(868, 0)
End SubPrivate Sub Command3_Click()
Dim l
Dim phandle
l = Shell("D:\test\test.exe")
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, l)
MsgBox phandle
End Sub
ProcessStartInfo pi=new ProcessStartInfo("notepad");
Process pp=Process.Start(pi);
this.txt_ID.Text=pp.Id.ToString();
将Id保留,下次启动粘贴到txt_ID
int ii=Convert.ToInt16(txt_ID.Text);
Process pp=Process.GetProcessById(ii);pp.Kill();
用API的TerminateProces也应该是一样的