axmol/templates/lua-template-runtime/frameworks/runtime-src/proj.win32/Runtime_win32.cpp

31 lines
614 B
C++
Raw Normal View History

2014-03-11 16:52:06 +08:00
#include <io.h>
#include <direct.h>
#include <stdio.h>
#include <vector>
#include <string>
#include "cocos2d.h"
using namespace std;
string getIPAddress()
{
2014-05-05 21:04:04 +08:00
WSADATA wsaData;
char name[155]={0};
char *ip=nullptr;
PHOSTENT hostinfo;
2014-03-11 16:52:06 +08:00
2014-05-05 21:04:04 +08:00
if ( WSAStartup( MAKEWORD(2,0), &wsaData ) == 0 )
{
if( gethostname ( name, sizeof(name)) == 0)
{
if((hostinfo = gethostbyname(name)) != NULL)
{
ip = inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list);
}
}
WSACleanup( );
}
return ip;
2014-03-11 16:52:06 +08:00
}