24,855
社区成员
发帖
与我相关
我的任务
分享
H:\>cl mywindow.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 16.00.30319.01 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
mywindow.cpp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:mywindow.exe
mywindow.obj
mywindow.obj : error LNK2019: unresolved external symbol __imp_DispatchMessageWreferenced in function wWinMain
mywindow.obj : error LNK2019: unresolved external symbol __imp_TranslateMessagereferenced in function wWinMain
mywindow.obj : error LNK2019: unresolved external symbol __imp_GetMessageW referenced in function wWinMain
mywindow.obj : error LNK2019: unresolved external symbol __imp_ShowWindow referenced in function wWinMain
mywindow.obj : error LNK2019: unresolved external symbol __imp_CreateWindowExW referenced in function wWinMain
mywindow.obj : error LNK2019: unresolved external symbol __imp_RegisterClassW referenced in function wWinMain
mywindow.obj : error LNK2019: unresolved external symbol __imp_DefWindowProcW referenced in function "__int64 __cdecl WindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?WindowProc@@YA_JPEAUHWND__@@I_K_J@Z)
mywindow.obj : error LNK2019: unresolved external symbol __imp_EndPaint referenced in function "__int64 __cdecl WindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?WindowProc@@YA_JPEAUHWND__@@I_K_J@Z)
mywindow.obj : error LNK2019: unresolved external symbol __imp_FillRect referenced in function "__int64 __cdecl WindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?WindowProc@@YA_JPEAUHWND__@@I_K_J@Z)
mywindow.obj : error LNK2019: unresolved external symbol __imp_BeginPaint referenced in function "__int64 __cdecl WindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?WindowProc@@YA_JPEAUHWND__@@I_K_J@Z)
mywindow.obj : error LNK2019: unresolved external symbol __imp_PostQuitMessage referenced in function "__int64 __cdecl WindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?WindowProc@@YA_JPEAUHWND__@@I_K_J@Z)
mywindow.exe : fatal error LNK1120: 11 unresolved externals
#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, PWSTR pCmdLine, int nCmdShow)
{
// Register the window class.
const wchar_t CLASS_NAME[] = L"Sample Window Class";
WNDCLASS wc = { };
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);
// Create the window.
HWND hwnd = CreateWindowEx(
0, // Optional window styles.
CLASS_NAME, // Window class
L"Learn to Program Windows", // Window text
WS_OVERLAPPEDWINDOW, // Window style
// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);
if (hwnd == NULL)
{
return 0;
}
ShowWindow(hwnd, nCmdShow);
// Run the message loop.
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);
}
@Set Path=C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\bin;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visual Studio 8\VC\vcpackages;%PATH%
@Set LIB=C:\Program Files\Microsoft Visual Studio 8\VC\lib;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Lib;%LIB%
@Set INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\include;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\include;%INCLUDE%
@Set NetSamplePath=C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0
@Set VCBUILD_DEFAULT_CFG=Debug^|Win32
@Set VCBUILD_DEFAULT_OPTIONS=/useenv
@echo Setting environment to use Microsoft .NET Framework v2.0 SDK tools.
@echo For a list of SDK tools, see the 'StartTools.htm' file in the bin folder.