I'm with stupid
"MYPROG.exe" is your average Win32 exe who needs to be closed. "CLOSEIT.exe" is the program to do that. "CLOSEIT.exe" is uses the below code to try and terminate the application. "CLOSEIT.exe" fails. "CLOSEIT.exe" observes that "MYPROG.exe" doesn't have a window, and has no WNDCLASS (or WNDCLASSEX) registered.
Code:
DWORD pid = 0;
HWND hWnd = FindWindow(NULL, "MYPROG.exe"); // I know it's wrong, whaddaya
// think this thread is for!
GetWindowThreadProcessId(hWnd, &pid);
if(!TerminateProcess(OpenProcess(PROCESS_TERMINATE, false, pid), 0))
MessageBox(NULL, "Failed to close...", "Error", NULL);
// code ends here
"CLOSEIT.exe" needs some help.
He's asking how to go about communicating with a process that doesn't have a window. I'd answer, but I don't know off the top of my head and am too lazy to go look it up in the MSDN Library.
Try using the CreateToolhelp32Snapshot() function. You can then walk the process list and find something with the right module name.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement