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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ExitProcess

Status
Not open for further replies.

minifiredragon

Programmer
Jun 29, 2003
68
US
I currently have created a process:

STARTUPINFO si;
PROCESS_INFORMATION pi;

GetStartupInfo(&si);


CreateProcess("C:\\Program Files\\Internet Explorer\\iexplore.exe",
"http:\\ // Name of app to launch
NULL, // Default process security attributes
NULL, // Default thread security attributes
FALSE, // Don't inherit handles from the parent
0, // Normal priority
NULL, // Use the same environment as the parent
NULL, // Launch in the current directory
&si, // Startup Information
&pi); // Process information stored upon return

and then go onto do better things.

Now I come to the point I want to Exit the process I created above. I was reading the ExitProcess on MSDN and quite frankly I don't understand (which is why I am here) how to tell the ExitProcess what to exit.

I see you can call:

GetExitCodeProcess
GetExitCodeThread

to get a thread process, but I thought the application was also a process? How do I know I am grabbing the right process to exit?

Help? Please?
 
try to use CloseHandle

Ion Filipski
1c.bmp
 
ExitProcess() will terminate the current process, so it will not do for what you want, since you want to terminate another process than the one you're in.

You can use TerminateProcess for this, though it's not a very clean way. You can also send a WM_CLOSE to the application window, which is a clean way to terminate it.

But, since you're starting internet explorer, why not use the COM interfaces of internet explorer? This provides a very clean way to start it, navigate to the site you want and probably also to terminate it again....

Greetings,
Rick
 
I was thinking that since Internet Explorer is itself it's own application which I am simply calling. Do I need to handle the destruction of process?? I was thinking that Internet Explorer would close itself when you pushed the X on the window.

I am just concerned about have a createprocess in my application and nothing to clean the memory it used.
 
Ah, so that's the only problem?
Well, no worries then; do what IonFilpski said: close the process handle.

Greetings,
Rick
 
if you open an IE as COM object you should call Release on this object to exit, or invoke method Quit/Exit if object's IDispatch* provide some of them. So, don't use WinAPI on COM objects. Better is to work with IE as COM object, but many users does not know COM, so they could use CreateProcess/CloseHandle.

Ion Filipski
1c.bmp
 
Since we are on the subject of closing internet explorer, I have one more thing that comes to mind. Am I capable of closing all the spawns of Internet Explorer (u know, them blasted pop-ups) from within the application? Or even ones created with the click of the Blue e?
 
It is possible only by using InternetExplorer AddIn model

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top