SDK/windows程序设计,最简单的hello worl 编译报错,败求指点
报错:errorLNK2001:unresolvedexternalsymbol"long__stdcallWndProc(structHWND__*,unsignedi...
报错:
error LNK2001: unresolved external symbol "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/NoteBook.exe : fatal error LNK1120: 2 unresolved externals
源码
/*----------------------------------------
NoteBook dante BAN meta_yy 2010
----------------------------------------*/
#include <windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hIstance,HINSTANCE hInstance,LPSTR lpCmdLine,int iCmdShow)
{
static TCHAR szAppName[] = TEXT("NoteBook by something");
HWND hwnd;
MSG msg;
WNDCLASS ws;
ws.style = CS_HREDRAW | CS_VREDRAW;
ws.lpfnWndProc = WndProc;
ws.cbClsExtra = 0;
ws.cbWndExtra = 0;
ws.hInstance = hInstance;
ws.hIcon = LoadIcon(NULL,IDI_APPLICATION);
ws.hCursor = LoadCursor(NULL,IDC_ARROW);
ws.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
ws.lpszMenuName = NULL;
ws.lpszClassName = szAppName;
if(!RegisterClass(&ws))
{
MessageBox(NULL,TEXT(" OH NO"),szAppName,MB_ICONERROR);
return 0;
}
hwnd = CreateWindow(
szAppName, // registered class name
TEXT("NOTEBOOK"), // window name
WS_OVERLAPPEDWINDOW, // window style
30, // horizontal position of window
30, // vertical position of window
500, // window width
300, // window height
NULL, // handle to parent or owner window
NULL, // menu handle or child identifier
hInstance, // handle to application instance
NULL // window-creation data
);
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WinProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch(message)
{
case WM_CREATE:
MessageBox(NULL,TEXT("Create Window"),TEXT("note"),MB_ICONERROR);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
DrawText(hdc,TEXT("HELLO WINDOWS"),-1,&rect,DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
另自学SDK中的朋友可以加个Q 指点一下新手 1136018016
VC++6.0下报错 ,创建的是win32控制台应用程序,。。 展开
error LNK2001: unresolved external symbol "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/NoteBook.exe : fatal error LNK1120: 2 unresolved externals
源码
/*----------------------------------------
NoteBook dante BAN meta_yy 2010
----------------------------------------*/
#include <windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hIstance,HINSTANCE hInstance,LPSTR lpCmdLine,int iCmdShow)
{
static TCHAR szAppName[] = TEXT("NoteBook by something");
HWND hwnd;
MSG msg;
WNDCLASS ws;
ws.style = CS_HREDRAW | CS_VREDRAW;
ws.lpfnWndProc = WndProc;
ws.cbClsExtra = 0;
ws.cbWndExtra = 0;
ws.hInstance = hInstance;
ws.hIcon = LoadIcon(NULL,IDI_APPLICATION);
ws.hCursor = LoadCursor(NULL,IDC_ARROW);
ws.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
ws.lpszMenuName = NULL;
ws.lpszClassName = szAppName;
if(!RegisterClass(&ws))
{
MessageBox(NULL,TEXT(" OH NO"),szAppName,MB_ICONERROR);
return 0;
}
hwnd = CreateWindow(
szAppName, // registered class name
TEXT("NOTEBOOK"), // window name
WS_OVERLAPPEDWINDOW, // window style
30, // horizontal position of window
30, // vertical position of window
500, // window width
300, // window height
NULL, // handle to parent or owner window
NULL, // menu handle or child identifier
hInstance, // handle to application instance
NULL // window-creation data
);
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WinProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch(message)
{
case WM_CREATE:
MessageBox(NULL,TEXT("Create Window"),TEXT("note"),MB_ICONERROR);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
DrawText(hdc,TEXT("HELLO WINDOWS"),-1,&rect,DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
另自学SDK中的朋友可以加个Q 指点一下新手 1136018016
VC++6.0下报错 ,创建的是win32控制台应用程序,。。 展开
展开全部
第一,应该新建工程 Win32 Application,然后选择空工程,添加一个源文件,输入代码
第二,你的消息处理函数名字有误
开头:LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); //这是你声明的函数
ws.lpfnWndProc = WndProc; //这里也正确,这是让windows以后调用这个函数处理事件
下面你定义的消息处理函数名字应该和上面的一样
LRESULT CALLBACK WinProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) //WinProc 拼错了,应该是WndProc
第二,你的消息处理函数名字有误
开头:LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); //这是你声明的函数
ws.lpfnWndProc = WndProc; //这里也正确,这是让windows以后调用这个函数处理事件
下面你定义的消息处理函数名字应该和上面的一样
LRESULT CALLBACK WinProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) //WinProc 拼错了,应该是WndProc
浙江启扬智能科技有限公司
2019-05-20 广告
2019-05-20 广告
目前开发板用Cortex-A9这个平台还是不错的,目前你处于学习阶段,更多的要考虑到是否可以提供很好的技术支持和帮助。做嵌入式开发板的公司很多,而且有很多渠道都可以买到。在某宝上,随随便便都可以买到,有的价格还很便宜。但是一分价钱一分货,往...
点击进入详情页
本回答由浙江启扬智能科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询