Link to home
Start Free TrialLog in
Avatar of raheelasadkhan
raheelasadkhanFlag for Pakistan

asked on

SendMessage WM_CLOSE to another process

I'm trying to use the SendMessage function to send the WM_CLOSE message to an external process. Even though the call returns 0, nothing happens and the target window does not close.

public const int WM_CLOSE = 0x10;
[DllImport("user32", EntryPoint="SendMessageA")]
public static extern Int32 SendMessage(Int32 hwnd, Int32 wMsg, Int32 wParam, Int32 lParam);

int result = WindowsEnumerator.SendMessage (hWnd, WM_CLOSE, 0, 0);

Is there something else I need to do to make the call valid for an external process?
Avatar of zstafa
zstafa

try

SendMessage(hWnd,0x0112,0xF060,0);
Avatar of raheelasadkhan

ASKER

What is the difference? What WM message do those values correspond to?

I also tried PostMessage(hWnd, WM_CLOSE, 0, 0) and it worked.

What would be the best way and why?
ASKER CERTIFIED SOLUTION
Avatar of zstafa
zstafa

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial