win32程序 为什么退出后 在任务管理器中的进程还看得到程序,该怎么处理

win32程序 为什么退出后 在任务管理器中的进程还看得到程序
#include <windows.h>
#include <stdio.h>

LRESULT CALLBACK AOWindowProc(
  HWND hwnd, // handle to window
  UINT uMsg, // message identifier
  WPARAM wParam, // first message parameter
  LPARAM lParam // second message parameter
);

int WINAPI WinMain(
  HINSTANCE hInstance, // handle to current instance
  HINSTANCE hPrevInstance, // handle to previous instance
  LPSTR lpCmdLine, // command line
  int nCmdShow // show state
  ){
WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.lpszClassName="at1559";
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.lpfnWndProc=AOWindowProc;
wndclass.lpszMenuName=NULL;
wndclass.style=CS_HREDRAW|CS_VREDRAW;

RegisterClass(&wndclass);
HWND hwnd;
hwnd=CreateWindow("at1559","window name",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWDEFAULT);
UpdateWindow(hwnd);

MSG msg;
while(GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}

LRESULT CALLBACK AOWindowProc(
  HWND hwnd, // handle to window
  UINT uMsg, // message identifier
  WPARAM wParam, // first message parameter
  LPARAM lParam // second message parameter
  )
{
PAINTSTRUCT ps;
switch(uMsg)
{
case WM_PAINT:
HDC hdc;
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,0,0,"你中毒了",strlen("你中毒了"));
EndPaint(hwnd,&ps);
break;
case WM_CHAR:
char ch[20];
sprintf(ch,"you press the %c",wParam);
MessageBox(hwnd,ch,"information",MB_OK);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"what's you want to do?","OMG!",MB_HELP);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"do you want to close?","close",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:return DefWindowProc(hwnd,uMsg,wParam,lParam); 
}
return 0;
}

------解决方案--------------------
我一直想知道
GetMessage(&msg,hwnd,0,0)
这种写法到底都是从哪儿看来的...

你用hwnd过滤消息,GetMessage根本收不到WM_QUIT,当然循环结束不了。

你得写GetMessage(&msg,0,0,0)
------解决方案--------------------
BOOL WINAPI GetMessage(
__out LPMSG lpMsg,
__in_opt HWND hWnd,
__in UINT wMsgFilterMin,
__in UINT wMsgFilterMax
);


hWnd [in, optional]
Type: HWND

A handle to the window whose messages are to be retrieved. The window must belong to the current thread. 





If hWnd is NULL, GetMessage retrieves messages for any window that belongs to the 
current thread, and any messages on the current thread's message queue whose hwnd value is NULL (see the MSG structure). Therefore if hWnd is NULL, both window messages and thread messages are processed.