Raised This Month: $32 Target: $400
 8% 

How can I fix these warnings?


Post New Thread Reply   
 
Thread Tools Display Modes
Guwashi
Junior Member
Join Date: Jan 2005
Old 06-28-2005 , 09:01  
Reply With Quote #11

Quote:
Originally Posted by BeetleFart
I dont know how to make the dll dynamically load.
Here is a sample code.
Code:
#ifdef _WIN32
#include <windows.h>
#include <winsock.h>
#else
#include <unistd.h>
#endif

#include <stdio.h>

#ifdef _WIN32
typedef int (__stdcall * WSAStartupProc)(WORD wVersionRequested, LPWSADATA lpWSAData);
typedef int (__stdcall * gethostnameProc)(char FAR* name, int namelen);
typedef int (__stdcall * WSACleanupProc)(void);
#endif

int main(int argc, char* argv[])
{
#ifdef _WIN32
  HINSTANCE hLib = LoadLibrary("wsock32.dll");
  if (!hLib) return 1;

  WSAStartupProc WSAStartup = (WSAStartupProc)GetProcAddress(hLib, "WSAStartup");
  if (!WSAStartup) return 1;
  gethostnameProc gethostname = (gethostnameProc)GetProcAddress(hLib, "gethostname");
  if (!gethostname) return 1;
  WSACleanupProc WSACleanup = (WSACleanupProc)GetProcAddress(hLib, "WSACleanup");
  if (!WSACleanup) return 1;


  WSADATA wsa;
  if (WSAStartup(MAKEWORD(1, 1), &wsa)) return 1;
#endif

  char hostname[256];
  int result = gethostname(hostname, sizeof(hostname));
  fprintf(stdout, "result == %d, hostname == %s\n", result, result == 0 ? hostname : "ERROR");

#ifdef _WIN32
  if (WSACleanup()) return 1;
#endif

  return 0;
}
Guwashi is offline
BeetleFart
SourceMod Donor
Join Date: Apr 2004
Old 06-28-2005 , 12:22  
Reply With Quote #12

Quote:
Originally Posted by Guwashi
Quote:
Originally Posted by BeetleFart
I dont know how to make the dll dynamically load.
Here is a sample code.
Code:
#ifdef _WIN32
#include <windows.h>
#include <winsock.h>
#else
#include <unistd.h>
#endif

#include <stdio.h>

#ifdef _WIN32
typedef int (__stdcall * WSAStartupProc)(WORD wVersionRequested, LPWSADATA lpWSAData);
typedef int (__stdcall * gethostnameProc)(char FAR* name, int namelen);
typedef int (__stdcall * WSACleanupProc)(void);
#endif

int main(int argc, char* argv[])
{
#ifdef _WIN32
  HINSTANCE hLib = LoadLibrary("wsock32.dll");
  if (!hLib) return 1;

  WSAStartupProc WSAStartup = (WSAStartupProc)GetProcAddress(hLib, "WSAStartup");
  if (!WSAStartup) return 1;
  gethostnameProc gethostname = (gethostnameProc)GetProcAddress(hLib, "gethostname");
  if (!gethostname) return 1;
  WSACleanupProc WSACleanup = (WSACleanupProc)GetProcAddress(hLib, "WSACleanup");
  if (!WSACleanup) return 1;


  WSADATA wsa;
  if (WSAStartup(MAKEWORD(1, 1), &wsa)) return 1;
#endif

  char hostname[256];
  int result = gethostname(hostname, sizeof(hostname));
  fprintf(stdout, "result == %d, hostname == %s\n", result, result == 0 ? hostname : "ERROR");

#ifdef _WIN32
  if (WSACleanup()) return 1;
#endif

  return 0;
}

Thanks alot..

Isnt their a command I have to put into my settings (make file)
to tell it also?
__________________
CSource Server:
69.90.34.10:27015 Beetlesmod.com And CS-Addicts{US}



http://www.clanuseast.com
BeetleFart is offline
Guwashi
Junior Member
Join Date: Jan 2005
Old 07-01-2005 , 00:18  
Reply With Quote #13

Quote:
Originally Posted by BeetleFart
Isnt their a command I have to put into my settings (make file)
to tell it also?
It could compile without any additional settings.
I just created a Win32 console application project with empty files, then added main.cpp which include this code.
Guwashi is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:37.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode