quote:
Originally posted by Plan-1130
code:
Interop.Call("User32", "SendMessageW", hWnd, 0x10, 0, 0);
actually SendMessageW will force the close command to be executed immidiately, for the mainwindow that might work, but using PostMessageW just puts the close command at the end of the line...
Use instead:
code:
Interop.Call("User32", "PostMessageW", hWnd, 0x10, 0, 0);
if you want to play it safe.
Nothing is forced in either of them. The only difference is that SendMessage will wait until the message is processed. Which is in almost all code, prefereable. PostMessage returns immediatly and this can lead to many bugs in your code as it is not sure if the message is processes in time and thus things after this code line will be executed immediatly which in many cases should wait until the window has been closed (eg: clearing up handles, closing files, etc).
Also, this is part of the reason that I ask for far more details of him as everything depends on what he exactly wants and what it will be used for.
(PS: FYI, messenger itself does also a sendmessage when sending WM_CLOSE)