- 积分
- 140
贡献71
飞刀0 FD
注册时间2011-9-23
在线时间61 小时
扫一扫,手机访问本帖
|
照着教学视频自己写了个hello world程序,如下:
#include <Windows.h>
#include<wingdi.h>
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdline,
int nCmdShow)
{
//1、创建一个窗体类
WNDCLASS wc;
wc.cbWndExtra = 0;
wc.cbClsExtra = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.hCursor = 0;
wc.hIcon = 0;
wc.hInstance =hInstance;
wc.lpfnWndProc =WndProc;
wc.lpszClassName = TEXT("hello__world");
wc.lpszMenuName = 0;
wc.style = CS_HREDRAW | CS_VREDRAW;
//2、注册窗体类
if(! RegisterClass(&wc)) return -1;
//3、创建一个窗体
HWND hwnd = CreateWindow(TEXT("hello__world"),TEXT("myfirstwindows"),WS_VISIBLE | WS_BORDER | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CAPTION,20,20,200,100,NULL,NULL,hInstance,NULL);
//4、更新内容并显示
UpdateWindow(hwnd);
ShowWindow(hwnd,nCmdShow);
//5、获取windows消息并处理
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 1;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
RECT rect;
GetClientRect(hwnd,&rect);
if(message == WM_DESTROY)
{
PostQuitMessage(1);
}
if(message == WM_PAINT)
{
hdc = BeginPaint(hwnd,&ps);
DrawText(hdc,TEXT("hello__world"),0,&rect,DT_CENTER | DT_VCENTER);
EndPaint(hwnd,&ps);
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
最后改到基本和教学视频里一样了,可编译还是有错,如下:hello word1.obj : error LNK2019: unresolved external symbol __security_cookie referenced in function "long __cdecl WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YAJPAUHWND__@@IIJ@Z)
hello word1.obj : error LNK2019: unresolved external symbol __security_check_cookie referenced in function "long __cdecl WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YAJPAUHWND__@@IIJ@Z)
LIBCMT.lib(gshandler.obj) : error LNK2001: unresolved external symbol __security_check_cookie
Pocket PC 2003 (ARMV4)\Release/hello world1.exe : fatal error LNK1120: 2 unresolved externals
谷歌了一下,说是没添加什么特定的库,可是照他们说的改了下设置,还是这样,版主在教学视频里也没特别强调要改什么设置啊,
小弟搞了一晚上也没搞出来,:'( 还请版主赐教啊!!! |
|