I can see a program running in the Close Program box, but there is no window for it. How can I get a handle or something to it, and then send it a message?
Printable View
I can see a program running in the Close Program box, but there is no window for it. How can I get a handle or something to it, and then send it a message?
I think.Code:HWND h = FindWindow(NULL, "Title Of The Window");
//h = the hwnd of the window
:)
I tried that but it didn't work, because there is no window, Basically, it is minimized to the system tray.
GetProcessHandle or something like that?
Even something that is minimized to the tray needs a window. The problem is knowing it's class (try Spy++ to find out).
e.g. ICQ always has the dialog window. Problem is, since it's created by the system, the class name is not always the same.
2 things:
1) If I don't know its class, is there any other way?
2) Say I do get the class name. What do I do then? I don't see any API functions about getting a process handle other than the current one.
OpenProcess can give you a process handle by id, but I don't know how to get the id.
Function names work only for WinNT, Win9x uses other methods.
EnumProcesses will give you the IDs of all processes that are currently running. Use OpenProcess to get a handle from the ID. Then use EnumProcessModules to get all module handles of a process. Get the file name of the module with GetModuleFileNameEx and search for the .exe file.