raheelasadkhan
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.SendMess age (hWnd, WM_CLOSE, 0, 0);
Is there something else I need to do to make the call valid for an external process?
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.SendMess
Is there something else I need to do to make the call valid for an external process?
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?
I also tried PostMessage(hWnd, WM_CLOSE, 0, 0) and it worked.
What would be the best way and why?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SendMessage(hWnd,0x0112,0x