#include <windows.h>
#include "EXE_DLL_NetHelp.h"
#include <IOSTREAM.H>
#pragma comment(lib,"DLL_NetHelp.lib")
void main()
{
char pHostIp[260];
char pHostName[260] = "smsblserver";
if (!DLL_NH_GetHostIPFromNameA(pHostName,pHostIp))
{
cout<<"获取局域网内smsblserver主机的地址成功:"<<pHostIp<<endl;
}
else
{
cout<<"获取局域网内smsblserver主机的地址失败!"<<endl;
}
}
头文件EXE_DLL_NetHelp.h是:
#ifndef DLLAPI
#ifdef _USRDLL
#ifdef __cplusplus
#define DLLEXPORT extern "C" __declspec(dllexport)
#else
#define DLLEXPORT __declspec(dllexport)
#endif
#define DLLAPI DLLEXPORT
#else /* Not BUILDING_DLL */
#ifdef __cplusplus
#define DLLIMPORT extern "C" __declspec(dllimport)
#else
#define DLLIMPORT __declspec(dllimport)
#endif
#define DLLAPI DLLIMPORT
#endif /* Not BUILDING_DLL */
#endif
DLLAPI BOOL WINAPI
DLL_NH_GetHostIPFromNameA(LPSTR lpHostName,LPSTR lpIP);
dll和lib文件见我的下载。