C语言窗口问题,我用vc运行了以下代码,结果显示 error LNK2001: unresolved external symbol _main
#include<windows.h>LRESULTCALLBACKWndproc(HWND,UINT,WPARAM,LPARAM);//windpwsmain'dicl...
#include<windows.h>
LRESULT CALLBACK Wndproc(HWND,UINT,WPARAM,LPARAM);//windpws main' diclare
//以下初始化窗口类
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR IpszCmdLine,int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcex;
char IpszClassName[]="窗口";
char IpszTitle[]="My_Windows";
//窗口类定义
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)Wndproc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance,IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName =IpszClassName;
wcex.hIconSm = LoadIcon(wcex.hInstance, IDI_HAND);
//以下进行窗口类的注册
if(!RegisterClassEx(&wcex))
{
MessageBeep(0);
return FALSE;
}
//创建窗口
hwnd=CreateWindow(IpszClassName,IpszTitle,WS_OVERLAPPEDWINDOW ,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
//窗口函数
LRESULT CALLBACK Wndproc(HWND hwnd,UINT message,WPARAM wParam,LPARAM Iparam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,Iparam);
}
return 0;
}
为什么,以及如何解决
我知道怎么解决了,还想问一下,怎么把他和c源代码合并啊 展开
LRESULT CALLBACK Wndproc(HWND,UINT,WPARAM,LPARAM);//windpws main' diclare
//以下初始化窗口类
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR IpszCmdLine,int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcex;
char IpszClassName[]="窗口";
char IpszTitle[]="My_Windows";
//窗口类定义
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)Wndproc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance,IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName =IpszClassName;
wcex.hIconSm = LoadIcon(wcex.hInstance, IDI_HAND);
//以下进行窗口类的注册
if(!RegisterClassEx(&wcex))
{
MessageBeep(0);
return FALSE;
}
//创建窗口
hwnd=CreateWindow(IpszClassName,IpszTitle,WS_OVERLAPPEDWINDOW ,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
//窗口函数
LRESULT CALLBACK Wndproc(HWND hwnd,UINT message,WPARAM wParam,LPARAM Iparam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,Iparam);
}
return 0;
}
为什么,以及如何解决
我知道怎么解决了,还想问一下,怎么把他和c源代码合并啊 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询