HANDLE OpenProcess( DWORD dwDesiredAccess, // access flag BOOL bInheritHandle, // handle inheritance option DWORD dwProcessId // process identifier );BOOL TerminateProcess( HANDLE hProcess, // handle to the process UINT uExitCode // exit code for the process );
你查一下吧,我忘了,原来做过类似的东西,不过你要注意unicode的问题,
否则标题不是英文时,得到的句柄为null.
不用我帮你查那个函数了吧。
DWORD dwDesiredAccess, // access flag
BOOL bInheritHandle, // handle inheritance option
DWORD dwProcessId // process identifier
);BOOL TerminateProcess(
HANDLE hProcess, // handle to the process
UINT uExitCode // exit code for the process
);
不过用FindWindow()时,需要知道该窗口的类名或窗口标题,这可以通过spy++工具轻易获得!
然后 hwnd = findwindow(classname,windowname);
PostMessage(hwnd,wm_close,wPara,lParam);
wm_close,wm_destroy,都可以。
就看你的另外一个应用程序响应哪个消息了。