当我尝试通过VS2013构建时出现LNK2019,LNK1120错误

时间:2014-10-06 07:19:49

标签: winapi visual-studio-2013 lnk2019

这是原始代码。

 #include <windows.h>

LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);

 int WINAPI Winmain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmdLine, int nCmdShow)
{

HWND hwnd;
MSG msg;
WNDCLASS WndClass;
WndClass.style = CS_HREDRAW | CS_VREDRAW;
WndClass.lpfnWndProc = WndProc;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hInstance = hInstance;
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.lpszMenuName = NULL;
WndClass.lpszClassName = "Window Class Name";
RegisterClass(&WndClass);
hwnd = CreateWindow("Window Class Name", "Window Title Name", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);

ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg, NULL, 0, 0))
{
    TranslateMessage(&msg);
    DispatchMessage(&msg);
}
return msg.wParam;
}

 LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
 {
HDC hdc;
PAINTSTRUCT ps;
RECT rect;

switch (iMsg)
{
case WM_CREATE:
    break;
case WM_PAINT:
    hdc = BeginPaint(hwnd, &ps);
    //TextOut(hdc, 0, 0, "HelloWorld", 10);
    rect.left = 50;
    rect.top = 40;
    rect.right = 200;
    rect.bottom = 120;
    DrawText(hdc, "HelloWorld", 10, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
    EndPaint(hwnd, &ps);
    break;
case WM_DESTROY:
    PostQuitMessage(0);
    break;
}
return DefWindowProc(hwnd, iMsg, wParam, lParam);

}

我认为此代码没有问题,但仍然存在致命错误LNK2019&amp; LNK1120。

我已经尝试过更改为控制台到Windows。但仍然相同。

任何人都可以帮助我吗?我无法检查API编程中的任何内容。

0 个答案:

没有答案