gpt4 book ai didi

c - 链接期间 WINAPI 出现奇怪的错误

转载 作者:行者123 更新时间:2023-11-30 17:41:06 25 4
gpt4 key购买 nike

这是我在链接过程中遇到的错误:

main.obj : error LNK2001: unresolved external symbol "long __stdcall windowProcess(struct HWND__ *,unsigned int,unsigned int,long)" (?windowProcess@@YGJPAUHWND__@@IIJ@Z)
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/main.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

main.exe - 3 error(s), 0 warning(s)

这是我的源代码

#include <windows.h>
//#include <stdlib.h>
//#include <string.h>
#include "stdafx.h"

//1. Declaring windowProcess of type LRESULT
//2. WIN API
//3. WIndow Class
//4. Register Class
//5. Create Window
//6. Show Window

// The main window class name
const char myClassName[] = "myClass";



//1. Moving towards 1st step & showing the ass of Window Process
LRESULT CALLBACK windowProcess(HWND,UINT,WPARAM,LPARAM);

//2. Using win api
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevIntance,
LPSTR lpcmdLine,
int comandNumber){

WNDCLASS wc;
wc.style=CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc=windowProcess;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_APPLICATION));
wc.hbrBackground=NULL;
wc.lpszMenuName=NULL;
wc.lpszClassName=myClassName;

//3. Registering Wnd Class
if(!RegisterClass(&wc))
{
MessageBox(NULL,"Class didnot get registered","An Simple Window Application",NULL);
}
//hint=hInstance;

//4. registering window class
HWND hWnd=CreateWindow(myClassName,"Title f Window",WS_OVERLAPPEDWINDOW,0,0,500,100,NULL,NULL,hInstance,NULL);

if(!hWnd)
{
MessageBox(NULL,"window didnt created","An Simple Windw Application",NULL);
}
//5. Now after window has been created lets show this window
ShowWindow(hWnd,comandNumber);
UpdateWindow(hWnd);
return 1;
}//winapi WinMain function ends

最佳答案

该错误告诉您该函数

LRESULT CALLBACK windowProcess(HWND,UINT,WPARAM,LPARAM);

仅在任何地方声明和定义。

关于c - 链接期间 WINAPI 出现奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21262767/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com