One nasty trick (on 32-bit OS only) is to write a few bytes to disk containing a 16-bit DOS exe which kills the 32-bit parent process and then itself.
This works fine in assembler:
CASE WM_DESTROY
invoke PostQuitMessage, NULL
Launch Cat$("cmd.exe /c del "+CL$(0)), SW_HIDE, 1 ; timeout 1 ms
... but no success with what seems to me the C equivalent:
case WM_DESTROY:
{
char buffer[300]; // MAX_PATH+15, ca.
lstrcpy(buffer, "cmd.exe /c del ");
GetModuleFileName(0, buffer+15, 285);
// MessageBox(0, buffer, 0, MB_OK);
PostQuitMessage(0);
system(buffer);
}
GOTCHA!! Forget system...
case WM_DESTROY:
{
char buffer[300]; // MAX_PATH+15, ca.
lstrcpy(buffer, "cmd.exe /c del ");
GetModuleFileName(0, buffer+15, 285);
PostQuitMessage(0);
WinExec(buffer, SW_HIDE);
}