Search code examples
.netwinapic++-cli

How do I gracefully close another application?


I have a C++/CLI based install application which needs to close another app I've written, replace the application's .exe and dlls and the re-run the executable.

First of all I need to close that window along the following lines:

HWND hwnd = FindWindow(NULL, windowTitle);
if( hwnd != NULL )
{
    ::SendMessage(hwnd, (int)0x????, 0, NULL);
}

I.e. find a matching window title (which works) ...but then what message do I need send the remote window to ask it to close?

...or is there a more .net-ish way of donig this without resorting to the windows API directlry?

Bare in mind that I'm limited to .net 2.0


Solution

  • WM_CLOSE?