16,472
社区成员
发帖
与我相关
我的任务
分享
#include <windows.h>
#include <tchar.h>
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS wndclass;
wndclass.lpfnWndProc = WindowProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpszClassName = _T("我的窗体");
wndclass.hInstance = hInstance;
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hIcon = 0;
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wndclass.lpszMenuName = 0;
if(RegisterClass(&wndclass) == 0)
{
MessageBox(0, _T("错误"), _T("错误"), MB_OK);
return 0;
}
HWND hWnd = CreateWindow(_T("我的窗体"), _T("第一个窗体"), WS_OVERLAPPEDWINDOW, 0, 0, 200, 300, 0, 0, hInstance, 0);
if(hWnd == NULL)
{
MessageBox(0, _T("失败"), _T("失败"), MB_OK);
return 0;
}
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
--------------------Configuration: API_01 - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/API_01.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
API_01.exe - 1 error(s), 0 warning(s)