It appears terminateprocess isn't really all that clean of a method to terminate a process. I saw a post on another forum by scronty http://www.asmcommunity.net/board/index.php?topic=229.0 which indicated a proper way to terminate a process would be to use the BroadcastSystemMessage function. I haven't seen any asm examples of this nor have seen much discusson about it. What would be the proper way to use the BroadcastSystemMessage function?
If the app you want to shut down is designed to receice this message, it should work fine.
WM_SHUTDOWN = RegisterWindowMessage("close_my_app")
SendMessage %HWND_BROADCAST,WM_SHUTDOWN,0,0
process it in the WndProc with,
Case WM_SHUTDOWN
I've looked into the message WM_SHUTDOWN but I can't find any informaton on it. Can you explain this a little better please.
What sort of process? Usually sending WM_CLOSE to the main window will be enough.
Or are you trying to force an app to close?
The trouble with BroadcastSystemMessage seems to be that it's not selective - it's a broadcast, so every app receives it (and/or driver, etc.)
azdps,
Look at the API that defined the message, WM_SHUTDOWN is the variable for the return value of RegisterWindowMessage(), thats why you can't find the name. If BOTH apps register the same message then using SendMessage with the HWND_BROADCAST value for the handle and the defined message, one app can communicate with another by this method.
Quote from: sinsi on June 14, 2008, 05:40:38 AM
What sort of process? Usually sending WM_CLOSE to the main window will be enough.
Or are you trying to force an app to close?
To clarify, my application needs to terminate explorer.exe, then immediately afterwards it will restart it. By shutting down and restarting explorer.exe someone using the application won't need to restart the computer. I have it setup right now using terminateprocess which works fine but I don't like the fact that it can create system stability issues.
Quote from: hutch-- on June 14, 2008, 12:53:09 PM
Look at the API that defined the message, WM_SHUTDOWN is the variable for the return value of RegisterWindowMessage(), thats why you can't find the name. If BOTH apps register the same message then using SendMessage with the HWND_BROADCAST value for the handle and the defined message, one app can communicate with another by this method.
what I don't understand now is how can I get the explorer.exe process to regster the same message.
> what I don't understand now is how can I get the explorer.exe process to regster the same message.
You can't so I would be inclined to keep using the method you are already using.