我試圖啓動iexplore.exe
讓它運行5秒鐘,然後再關閉它。如何使用PostThreadMessage從C++關閉Internet Explorer
iexplore
打開就好,但是當我調用PostThreadMessage時它不會關閉。 任何人都可以看到我做錯了什麼?這裏是我的代碼:
CString IEPath = "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE";//GetIEPath();
//IEPath += ' ' + url;
std::string strCommand((LPCTSTR)IEPath);
PROCESS_INFORMATION procinfo;
STARTUPINFO startupinfo;
GetStartupInfo(&startupinfo);
CreateProcess(
NULL,
(char *)strCommand.c_str(),// name of executable module
NULL, // lpProcessAttributes
NULL, // lpThreadAttributes
false, // handle inheritance option
CREATE_SHARED_WOW_VDM, // creation flags
NULL, // new environment block
NULL, // current directory name
&startupinfo, // startup information
&procinfo // process information
);
Sleep(5000);
::PostThreadMessage(procinfo.dwThreadId, WM_QUIT, 0, 0); //<---Dosent Close internet explorer!
任何人都知道我做錯了什麼?或者有更好的方法去做什麼?
我希望避免窗口的enumration,因爲我得到的句柄,進程和線程。 – CruelIO 2008-11-11 09:16:34