#include "stdafx.h"
#include <windows.h>
#include <winsock.h>
#include <stdio.h>
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR IpCmdLine,int nCmdShow)
{
WSADATA ws;
char buf[100];
WSAStartup(0x0101,&ws);
sprintf(buf,"%d.%d",HIBYTE(ws.wVersion),LOBYTE(ws.wVersion));
MessageBox(0,buf,"info",0);
WSACleanup();
return 0;
}
This program is for getting information of available wsock version in the computer. I cannot understand why "stdafx.h" is included in program. What's the significance of APIENTRY? Can't we use _stdcall instead? I also can't compile it in VC++. What's the problem with the code?
Below are the errors when executing program there are no errors during compiling.
--------------------Configuration: sa - Win32 Debug--------------------
Linking...
sa.obj : error LNK2001: unresolved external symbol _WSACleanup@0
sa.obj : error LNK2001: unresolved external symbol _WSAStartup@8
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/sa.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
sa.exe - 4 error(s), 0 warning(s)