#include <Windows.h>
#include <stdlib.h>
#include <tchar.h>
#pragma comment(linker,"\"/manifestdependency:type='win32'name='Microsoft.Windows.Common-Controls'\
version='6.0.0.0' processorArchitecture='*'\
publicKeyToken='6595b64144ccf1df' language='*'\"")
LRESULT WINAPI WndProc(HWND hWnd,UINT msg,WPARAM lParam,LPARAM wParam)
{
return DefWindowProc(hWnd,msg,wParam,lParam);
}
int WinMain(HINSTANCE hInst,HINSTANCE hpInst,LPSTR cmdLine,int cmdshow)
{
static TCHAR classname[]=_T("SCONF");
static TCHAR wTitle[]=_T("Server Configurator");
WNDCLASSEX wClass;
wClass.cbClsExtra=NULL;
wClass.cbSize=sizeof(WNDCLASSEX);
wClass.cbWndExtra=NULL;
wClass.hbrBackground=(HBRUSH)(CTLCOLOR_SCROLLBAR);
wClass.hCursor=LoadCursor(NULL,IDC_ARROW);
wClass.hIcon=LoadIcon(hInst,IDI_APPLICATION);
wClass.hIconSm=LoadIcon(hInst,IDI_APPLICATION);
wClass.hInstance=hInst;
wClass.lpfnWndProc=WndProc;
wClass.lpszClassName=classname;
wClass.lpszMenuName=NULL;
wClass.style=CS_HREDRAW|CS_VREDRAW;
if(!RegisterClassEx(&wClass))
{
MessageBox(NULL,L"Could not register class!", L"ERROR",MB_ICONERROR|MB_OK);
}
RECT wr={0,0,200,250};
AdjustWindowRect(&wr,WS_CAPTION,false);
HWND hWnd=CreateWindow(
classname,
wTitle,
WS_CAPTION,
GetSystemMetrics(SM_CXSCREEN)/2-100,
GetSystemMetrics(SM_CYSCREEN)/2-125,
wr.right-wr.left,//width
wr.bottom-wr.top,//height
NULL,
NULL,
hInst,
NULL);
if(!hWnd)
{
MessageBox(NULL,_T("Could not create window!"),_T("ERROR!"),MB_ICONERROR);
return 1;
}
ShowWindow(hWnd,cmdshow);
MSG msg;
while(GetMessage(&msg,0,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
这是完整的代码,当我尝试编译时,hWnd 总是返回 false...我什至尝试从工作程序中复制代码但它没有工作...这是怎么回事?之前一直有效...