vc建立win32简略程序 运行无窗体

vc建立win32简单程序 运行无窗体
点击运行的时候,好像没有什么反应。
C/C++ code

// MyWindows.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

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


int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
     // TODO: Place code here.
    WNDCLASS myclass;
    myclass.style= CS_HREDRAW | CS_VREDRAW;
    myclass.lpszClassName="MyClass";
    myclass.hInstance=hInstance;
    myclass.lpfnWndProc=MyProc;
    HWND h1=CreateWindow("MyClass","Hello the first Window",WS_VISIBLE,100,100,200,200,NULL,NULL,hInstance,NULL);
    ShowWindow(h1,SW_SHOWNORMAL);
    UpdateWindow(h1);
    return 0;
}




------解决方案--------------------
你需要一个隐藏的窗体。
------解决方案--------------------
删一个就不对了
// MyWindows.cpp : Defines the entry point for the application.
//

#include<windows.h>

LRESULT CALLBACK MyProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
if(uMsg==WM_DESTROY)PostQuitMessage(0);
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}


int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int iCmdShow)
{

MSG msg;
WNDCLASS myclass;
HWND h1;

myclass.cbClsExtra=0;
myclass.cbWndExtra=0;
myclass.style= CS_HREDRAW | CS_VREDRAW;
myclass.hInstance=hInstance;
myclass.hIcon=LoadIcon(NULL,IDI_WINLOGO);
myclass.hCursor=LoadCursor(NULL,IDC_ARROW);
myclass.lpfnWndProc=(WNDPROC)MyProc;
myclass.hbrBackground=(HBRUSH)(CreateSolidBrush(RGB(0,0,255)));
myclass.lpszClassName="MyWndClass";
myclass.lpszMenuName = NULL ;

RegisterClass(&myclass);
h1=CreateWindow("MyWndClass","Hello the first Window",WS_SIZEBOX|WS_SYSMENU,100,100,200,200,HWND_DESKTOP,NULL,hInstance,NULL);
ShowWindow(h1,SW_SHOW);
UpdateWindow(h1);
while(GetMessage(&msg,NULL,0,0))
 {
TranslateMessage(&msg);
DispatchMessage(&msg);
 }
 return msg.wParam;

}