Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use PostThreadMessage to close internet explore

Status
Not open for further replies.

CruelIO

Programmer
Apr 15, 2005
5
DK
Hi
Im trying to start iexplore.exe let it run for 5 seconds and then close it again.

iexplore opens just fine however it doest close when i call the PostThreadMessage can any one see what im doing wrong here is the code:



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!

Anyone have an idea of what im doing wrong? Or is there at better what to do the trick?

Thank you

 
Try using TerminateProcess() instead of PostThreadMessage().

Good Luck,

Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top