Linking...
Generic.obj : error LNK2001: unresolved external symbol "int __cdecl InitInstance(void *,int)" (?InitInstance@@YAHPAXH@Z)
Generic.obj : error LNK2001: unresolved external symbol "int __cdecl InitApplication(void *)" (?InitApplication@@YAHPAX@Z)
Debug/FirstWin.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
Creating browse info file...这是创建窗口的基本程序
我一直用Delphi,学VC,在VC创建Win32 Application工程,还不知道这是什么错误.源代码
Generic.h
BOOL InitApplication(HANDLE hInstance);
BOOL InitInstance(HANDLE hInstance,int nCmdShow);
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
LRESULT CALLBACK About(HWND,UINT,WPARAM,LPARAM);Generic.cpp
#include <windows.h>
#include "Generic.h"
#include "resource.h"HINSTANCE _hInst; //实例句柄
HWND _hWnd; //窗口句柄char _szAppName[]="Generic"; //程序名称
char _szTitle[]="莫祖繁的窗口";//-----------------------------------------------------------------
// WinMain - 程序的入口点
//-----------------------------------------------------------------
int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR lpCmdLine,int nCmdShow)
{
MSG msg;
UNREFERENCED_PARAMETER(lpCmdLine); //避免编译时警告
if (!hPreInstance)
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; //not used (should be zero) MSDN
wc.cbWndExtra=0; //not used (should be zero) MSDN
wc.hInstance=hInstance; //窗体实例
wc.hIcon=LoadIcon(hInstance,"jjhouricon"); //读取图标
wc.hCursor=LoadCursor(NULL,IDC_ARROW); //读取光标
wc.hbrBackground= WHITE_BRUSH; //GetStockObject(WHITE_BRUSH); //窗体后台颜色
wc.lpszMenuName="GenericMenu";
wc.lpszClassName = _szAppName;
return (RegisterClass(&wc));
}//--------------------------------------------------------------------
// InitInstance - 产生窗体
//--------------------------------------------------------------------
BOOL InitInstance(HINSTANCE hInstance,int nCmdShow)
{
_hInst=hInstance; //储存为全局变量 _hWnd=CreateWindow(
_szAppName,
_szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
if (!_hWnd)
return (FALSE);
ShowWindow(_hWnd,nCmdShow); //显示窗口
UpdateWindow(_hWnd);
return(TRUE);
}//------------------------------------------------------------
// WndProc - 窗口函数
//------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,
WPARAM wParam,LPARAM lParam)
{
int hmId,wmEvent; switch (message) {
case WM_COMMAND:
hmId=LOWORD(wParam);
wmEvent=HIWORD(wParam); switch (hmId){
case IDM_ABOUT:
DialogBox(_hInst,
"AboutBox",
hWnd,
(DLGPROC)About
);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return(DefWindowProc(hWnd,message,wParam,lParam));
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return(DefWindowProc(hWnd,message,wParam,lParam));
}
return(0);
}//------------------------------------------------------------
// About - 对话框函数
//------------------------------------------------------------
LRESULT CALLBACK About(HWND hDlg,UINT message,
WPARAM wParam,LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam); //避免编译时的警告
switch (message) {
case WM_INITDIALOG:
return (TRUE);
case WM_COMMAND:
if (LOWORD(wParam)==IDOK || LOWORD(wParam)==IDCANCEL) {
EndDialog(hDlg,TRUE);
return(TRUE); //TRUE 表示我已经处理过这个消息
}
break;
}
return(FALSE); //False表示我没有处理这个消息
}
Generic.obj : error LNK2001: unresolved external symbol "int __cdecl InitInstance(void *,int)" (?InitInstance@@YAHPAXH@Z)
Generic.obj : error LNK2001: unresolved external symbol "int __cdecl InitApplication(void *)" (?InitApplication@@YAHPAX@Z)
Debug/FirstWin.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
Creating browse info file...这是创建窗口的基本程序
我一直用Delphi,学VC,在VC创建Win32 Application工程,还不知道这是什么错误.源代码
Generic.h
BOOL InitApplication(HANDLE hInstance);
BOOL InitInstance(HANDLE hInstance,int nCmdShow);
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
LRESULT CALLBACK About(HWND,UINT,WPARAM,LPARAM);Generic.cpp
#include <windows.h>
#include "Generic.h"
#include "resource.h"HINSTANCE _hInst; //实例句柄
HWND _hWnd; //窗口句柄char _szAppName[]="Generic"; //程序名称
char _szTitle[]="莫祖繁的窗口";//-----------------------------------------------------------------
// WinMain - 程序的入口点
//-----------------------------------------------------------------
int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR lpCmdLine,int nCmdShow)
{
MSG msg;
UNREFERENCED_PARAMETER(lpCmdLine); //避免编译时警告
if (!hPreInstance)
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; //not used (should be zero) MSDN
wc.cbWndExtra=0; //not used (should be zero) MSDN
wc.hInstance=hInstance; //窗体实例
wc.hIcon=LoadIcon(hInstance,"jjhouricon"); //读取图标
wc.hCursor=LoadCursor(NULL,IDC_ARROW); //读取光标
wc.hbrBackground= WHITE_BRUSH; //GetStockObject(WHITE_BRUSH); //窗体后台颜色
wc.lpszMenuName="GenericMenu";
wc.lpszClassName = _szAppName;
return (RegisterClass(&wc));
}//--------------------------------------------------------------------
// InitInstance - 产生窗体
//--------------------------------------------------------------------
BOOL InitInstance(HINSTANCE hInstance,int nCmdShow)
{
_hInst=hInstance; //储存为全局变量 _hWnd=CreateWindow(
_szAppName,
_szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
if (!_hWnd)
return (FALSE);
ShowWindow(_hWnd,nCmdShow); //显示窗口
UpdateWindow(_hWnd);
return(TRUE);
}//------------------------------------------------------------
// WndProc - 窗口函数
//------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,
WPARAM wParam,LPARAM lParam)
{
int hmId,wmEvent; switch (message) {
case WM_COMMAND:
hmId=LOWORD(wParam);
wmEvent=HIWORD(wParam); switch (hmId){
case IDM_ABOUT:
DialogBox(_hInst,
"AboutBox",
hWnd,
(DLGPROC)About
);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return(DefWindowProc(hWnd,message,wParam,lParam));
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return(DefWindowProc(hWnd,message,wParam,lParam));
}
return(0);
}//------------------------------------------------------------
// About - 对话框函数
//------------------------------------------------------------
LRESULT CALLBACK About(HWND hDlg,UINT message,
WPARAM wParam,LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam); //避免编译时的警告
switch (message) {
case WM_INITDIALOG:
return (TRUE);
case WM_COMMAND:
if (LOWORD(wParam)==IDOK || LOWORD(wParam)==IDCANCEL) {
EndDialog(hDlg,TRUE);
return(TRUE); //TRUE 表示我已经处理过这个消息
}
break;
}
return(FALSE); //False表示我没有处理这个消息
}
解决方案 »
- 请教一个List Control与Tree Control结合的控件的实现
- InstallShield 删除 Shell Folder目录?? 今日结贴送分
- Access数据库突然只能以只读方式打开
- 关于MSDN上的一个例子,和SHBrowseForFolder有关的问题.
- 有那位高人知道关于vc++中的external dependencies吗?
- IDC_EDIT1是关联到控件类型成员上好,还是连到string上好呢?
- 请问:为什么在SELECT 后用了 DISTINCT 查找出来的记录就不能编辑了?谢谢!
- 怎么检查串口是否存在
- vc向另一个进程发出单击消息出问题了。。。
- 这个问题实在太怪了,我实在解决不了了!
- 再加100分,关于dx9安装的问题
- 如何处理CListCtrl被选中的消息
//#include "resource.h"BOOL InitApplication(HANDLE hInstance);
BOOL InitInstance(HANDLE hInstance,int nCmdShow);
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);HINSTANCE _hInst; //实例句柄
HWND _hWnd; //窗口句柄char _szAppName[]="Generic"; //程序名称
char _szTitle[]="莫祖繁的窗口";int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR lpCmdLine,int nCmdShow)
{
MSG msg;
if (!hPreInstance)
if (!InitApplication(hInstance))
return(FALSE);
if (!InitInstance(hInstance,nCmdShow))
return(FALSE) ;
while (GetMessage(&msg,NULL,0,0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return(msg.wParam);
}BOOL InitApplication(HINSTANCE hInstance)
{
WNDCLASS wc;
wc.style=CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc=(WNDPROC) WndProc; //函数窗口
wc.cbClsExtra=0; //not used (should be zero) MSDN
wc.cbWndExtra=0; //not used (should be zero) MSDN
wc.hInstance=hInstance; //窗体实例
wc.hIcon=LoadIcon(hInstance,"jjhouricon"); //读取图标
wc.hCursor=LoadCursor(NULL,IDC_ARROW); //读取光标
wc.hbrBackground= BLACK_BRUSH; //GetStockObject(WHITE_BRUSH); //窗体后台颜色
wc.lpszMenuName="GenericMenu";
wc.lpszClassName = _szAppName;
return (RegisterClass(&wc));
}BOOL InitInstance(HINSTANCE hInstance,int nCmdShow)
{
_hInst=hInstance; //储存为全局变量 _hWnd=CreateWindow(
_szAppName,
_szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
if (!_hWnd)
return (FALSE);
ShowWindow(_hWnd,nCmdShow); //显示窗口
UpdateWindow(_hWnd);
return(TRUE);
}//------------------------------------------------------------
// WndProc - 窗口函数
//------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,
WPARAM wParam,LPARAM lParam)
{
int hmId,wmEvent; switch (message) {
case WM_COMMAND:
hmId=LOWORD(wParam);
wmEvent=HIWORD(wParam); switch (hmId)
{
default:
return(DefWindowProc(hWnd,message,wParam,lParam));
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return(DefWindowProc(hWnd,message,wParam,lParam));
}
return(0);
}
但我不是很明白为什么用.CPP就不行