Opening and closing an application
-
I am trying to get my C program to open and close another application.
ShellExecute (NULL,"open","C:/myproject.exe",NULL,NULL,SW_RESTORE);
works to open the application, but I can't get it to close. I've triedDestroyWindow("C:/myproject.exe");
but it doesn't work. Can anyone tell me what to use for the file reference for DestroyWindow? Or is there a completely different way to do this better? squeaky -
I am trying to get my C program to open and close another application.
ShellExecute (NULL,"open","C:/myproject.exe",NULL,NULL,SW_RESTORE);
works to open the application, but I can't get it to close. I've triedDestroyWindow("C:/myproject.exe");
but it doesn't work. Can anyone tell me what to use for the file reference for DestroyWindow? Or is there a completely different way to do this better? squeakyHi squeaky Read my article below :- http://www.codeproject.com/system/newbiespawn.asp That'll show you how to use CreateProcess which gives you both the process handle and the thread handle for the main thread. Now use EnumWindows to enumerate all top level windows. Call GetWindowThreadProcessId on each HWND and compare with the thread ID you had saved earlier. If they match, post a WM_CLOSE message to this HWND. Hope this helps, Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]