0
#ifndef UNICODE
#define UNICODE
#endif
#include <windows.h>
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
const wchar_t CLASS_NAME[] = L"Sample Window Class";
WNDCLASS wc = { };
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);
HWND hwnd = CreateWindowEx(
0,
CLASS_NAME,
L"Learn to Program Windows",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
if (hwnd == NULL)
{
return 0;
}
ShowWindow(hwnd, nCmdShow);
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_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));
EndPaint(hwnd, &ps);
}
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
這是代碼,這也是你可以在微軟的網站,教人們如何Windows程序找到標準的例子。 http://msdn.microsoft.com/en-us/library/windows/desktop/ff381409(v=vs.85).aspx錯誤創建Windows中的一個窗口「未定義的引用‘的WinMain @ 16’」
無論何時我嘗試在代碼塊中編譯此代碼,我都會收到以下問題。
未定義的引用「的WinMain @ 16」
那是什麼,我能做些什麼來編譯和運行這段代碼?
是的,就是這樣。通過從 改變它INT WINAPI的WinMain(HINSTANCE的hInstance,HINSTANCE hPrevInstance,PWSTR pCmdLine,INT的nCmdShow) 到 INT WINAPI的WinMain(HINSTANCE的hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,INT的nCmdShow) 謝謝:) –
Èil problema microsoft:gli標準。 – lunadir
來一個sapere che io sia italiano嗎? O.O Comunque non posso votarti la rispostaperchèmi mancano 2di reputazione per votare。 Grazie comunqueperò:) –