大家帮我看看这么一个问题——————

feihong6 feihong6 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
编译时没错,但有一个WARNING!连接时错误如下:
Configuration: example1 - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/example1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

example1.exe - 2 error(s), 0 warning(s)
源代码如下:(
#include "stdafx.h"
//#include "stdlib.h"
//#include "string.h"
long WINAPI WndProc(HWND,UINT,UINT,LONG);
//void WINAPI CaretPos(int *xCaret,int *yCaret);
bool InitWindowsClass(HINSTANCE hInstance);
bool InitWindows(HINSTANCE hInstance,int nCmdShow);
HWND hWndMain;

//Ö÷º¯Êý
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.

MSG Message;

if(! InitWindowsClass(hInstance))
{
MessageBeep(0);
return false;
}
if(! InitWindows(hInstance,nCmdShow))
return false;




//ShowWindow(hwnd,nCmdShow);


//
while(GetMessage(&Message,NULL,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;

}

//
long WINAPI WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return(0);
}

bool InitWindowsClass(HINSTANCE hInstance)
{
WNDCLASS wndclass;

wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,"END");
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName="winkeyboard";
return (RegisterClass(&wndclass));
}

bool InitWindows(HINSTANCE hInstance,int nCmdShow)
{
HWND hwnd ;
hwnd=CreateWindow("winkeyboard",
"¼üÅ̲Ù×÷Àý×Ó",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
if(!hwnd)
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
return true;
}
...全文
评论 1
收藏 已收藏
分享
返回顶部
feihong6
VC/MFC 16,550 成员 421,606 内容