偶提个VC的新手问题,搞OD调试的高手相信不少都会VC,偶也不浪费时间去找VC论坛了,干脆在看雪直接提问吧。最近想学VC,到网上查到孙鑫老师的视频教程。自己调试下看看,出问题了。源码:
test.cpp:
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK WinSunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hprveinstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinSunProc;
wndcls.lpszClassName="Weixin2003";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW|CS_VREDRAW;
RegisterClass(&wndcls);
HWND hwnd;
hwnd=CreateWindow("Weixin2003","北京维新科学技术培训中心",WS_OVERLAPPEDWINDOW,
0,0,600,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinSunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,0,0,"北京维新科学技术培训中心",strlen("北京维新科学技术培训中心"));
EndPaint(hwnd,&ps);
break;
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is %d",wParam);
MessageBox(hwnd,szChar,"weixin",MB_OK);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"mouse clicked","weixin",MB_OK);
HDC hDC;
hDC=GetDC(hwnd);
TextOut(hDC,0,50,"计算机编程语言培训",strlen("计算机编程语言培训"));
ReleaseDC(hwnd,hDC);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"你是否要退出程序?","weixin",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
调试时候,编译米问题。但是就是米法创建.exe和.obj文件。错误提示为:
--------------------Configuration: test - Win32 Debug--------------------
Linking...
LINK : fatal error LNK1168: cannot open Debug/test.exe for writing
执行 link.exe 时出错.
test.exe - 1 error(s), 0 warning(s)
偶懂VB,VC现学现卖。肯定代码哪个地方有问题,偶实在米精力在某处错别字上浪费时间,请各位大虾指教。
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课