一段关闭进程的源码!
<P>void __fastcall TForm1::Button1Click(TObject *Sender){
DWORD TheProcessID, ErrorCode;
HWND TheWindowHandle=FindWindowEx(NULL,NULL,"IEFrame",NULL);
//找IE窗口
if(TheWindowHandle)
{
GetWindowThreadProcessId(TheWindowHandle,&TheProcessID);
//有的话,获取进程ID
HANDLE TheProcessHandle=OpenProcess(PROCESS_TERMINATE,false,TheProcessID);
TerminateProcess(TheProcessHandle, 0);
//杀掉
}
else
Application->MessageBox("There's no Internet Explorer window","ERROR",1);</P>
<P>}
//---------------------------------------------------------------------------</P>
<P>void __fastcall TForm1::Button2Click(TObject *Sender)
{
HWND TheWindowHandle= FindWindow("Tapplication", "Project1");
if(TheWindowHandle)//有的话就关掉
PostMessage(TheWindowHandle, WM_QUIT, 0, 0 );
}</P>
页:
[1]