//Generic.cpp
#include // 每一个 Windows 程序都需要包含此档
#include "resource.h" // 內含各个 resource IDs
#include "Generic.h" // 本程序之含入档
HINSTANCE _hInst; // Instance handle
HWND _hWnd;
char _szAppName[] = "Generic"; //
char _szTitle[] = "Generic Sample Application"; //
// WinMain -
//---------------------------------------------------------------
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
if (!hPrevInstance)
if (!InitApplication(hInstance))
return (FALSE);
if (!InitInstance(hInstance, nCmdShow))
return (FALSE);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam); //
}
//---------------------------------------------------------------
// InitApplication -
//---------------------------------------------------------------
BOOL InitApplication(HINSTANCE hInstance)
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WndProc; //
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground =(HBRUSH) GetStockObject(WHITE_BRUSH); //
wc.lpszMenuName = (LPCWSTR)"GenericMenu"; // .RC
wc.lpszClassName =(LPCWSTR) _szAppName;
return (RegisterClass(&wc));
}
//---------------------------------------------------------------
// InitInstance -
//---------------------------------------------------------------
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
_hInst = hInstance; //
_hWnd = CreateWindow(
(LPCWSTR)_szAppName,
(LPCWSTR)_szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
if (!_hWnd)
return (FALSE);
ShowWindow(_hWnd, nCmdShow); //
UpdateWindow(_hWnd); // 送出 WM_PAINT
return (TRUE);
}
//Generic.h
#include
BOOL InitApplication(HANDLE);
BOOL InitInstance(HANDLE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
生成时发生这样的错误:
1>Generic.obj : error LNK2019: 无法解析的外部符号 "int __cdecl InitInstance(void *,int)" (?InitInstance@@YAHPAXH@Z),该符号在函数 _WinMain@16 中被引用
1>Generic.obj : error LNK2019: 无法解析的外部符号 "int __cdecl InitApplication(void *)" (?InitApplication@@YAHPAX@Z),该符号在函数 _WinMain@16 中被引用
1>C:\Users\Share\Documents\Visual Studio 2010\Projects\firstwindow\Debug\firstwindow.exe : fatal error LNK1120: 2 个无法解析的外部命令
急急急~ 求大神指教。