All Winsock2 examples at MSDN shows that I have to statically link Winsock2 libarary as:
#pragma comment(lib, "ws2_32.lib")
Ensure that the build environment links to the Winsock Library file ?>Ws2_32.lib. Applications that use Winsock must be linked with the Ws2_32.lib >library file. The #pragma comment indicates to the linker that the Ws2_32.lib >file is needed.
But why I use it instead of simple loading an existing in Windows Ws2_32.dll (since Windows 2003 as I understand according to requirements at MSDN https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recv)
So I can use something like this:
typedef int WSAAPI(WINAPI* recv_func)(SOCKET s, char *buf, int len, int flags);
HINSTANCE hGetProcIDDLL = LoadLibraryA("ws2_32.dll");
my_recv = (recv_func)GetProcAddress(hGetProcIDDLL, "recv");
Or I can just use winsock2.h header and compile a program with /MD flag:
include <winsock2.h>
//#pragma comment(lib, "ws2_32.lib")
Is it possible? Can I use /MD or load ws2_32.dll dynamically as in first example without statically linking ws2_32.lib to my application because all Windows since Win2003 have ws2_32.dll it in System32 folder?
/MDhere unrelated. if you need use functions from ws2_32.lib you need somehow get it pointers. can be done by import it (use link with lib), or by resolving it yourself. but for what do second, when loader can do this for you ? - RbMm