在InstallShield中引用WINSOCK 的示例代码_脚本其他教程-查字典教程网
在InstallShield中引用WINSOCK 的示例代码
在InstallShield中引用WINSOCK 的示例代码
发布时间:2016-12-28 来源:查字典编辑
摘要:通过以下示例,InstallShield可以用WINSOCK获取IP地址,可将以下文件保存为tcpip.rul#defineWSADESCR...

通过以下示例,InstallShield可以用WINSOCK获取IP地址,可将以下文件保存为tcpip.rul

#defineWSADESCRIPTION_LEN256

#defineWSASYS_STATUS_LEN128

typedef

WSAData

begin

INTwVersion;

INTwHighVersion;

charszDescription[WSADESCRIPTION_LEN+1];

charszSystemStatus[WSASYS_STATUS_LEN+1];

shortiMaxSockets;

shortiMaxUdpDg;

POINTERlpVendorInfo;

end;

WSADatastructWSAData;

WSADataPOINTERpWSAData;

typedefHostEnt

begin

POINTERph_name;

POINTERph_aliases;

shorth_addrtype;

shorth_length;

POINTERph_addr_list;

end;

HostEntstructHostEnt;

HostEntPOINTERpHostEnt;

SHORTnlen;

NUMBERnIPNetAddr;

NUMBERnVersion;

STRINGszMsg;

STRINGszDefault;

STRINGszURL;

STRINGszPath;

NUMBERnRC;

NUMBERnRC2;

STRINGszHostName;

STRINGszMYIPAddr;

POINTERpWinSockReturn;

typedefIPName

begin

STRINGszIPAddr[100];

end;

IPNameLocalIPName;

IPNamePOINTERpLocalIPName;

typedefIPAddrList

begin

POINTERpIPAddr;

end;

IPAddrListstructIPAddrList;

IPAddrListPOINTERpIPAddrList;

typedefIPAddPtr

begin

LONGnIPAddr;

end;

IPAddPtrstructIPAddPtr;

IPAddPtrPOINTERpIPAddPtr;

POINTERpIN_Addr_Struct;

prototypePOINTERwsock32.gethostbyname(BYREFSTRING);

prototypePOINTERwsock32.gethostname(BYREFSTRING,NUMBER);

prototypePOINTERwsock32.WSAStartup(INT,POINTER);

prototypePOINTERwsock32.inet_ntoa(NUMBER);

prototypePOINTERwsock32.WSACleanup();

prototypeintwsock32.WSAGetLastError();

program

pWSAData=&structWSAData;

nRC=UseDLL("wsock32.dll");

pWSAData->wHighVersion=1;

pWSAData->wVersion=1;

nVersion=0x02000002;//0x01000001

pWinSockReturn=WSAStartup(nVersion,pWSAData);

pWinSockReturn=gethostname(szHostName,100);

pHostEnt=gethostbyname(szHostName);

nlen=pHostEnt->h_length;

pIPAddPtr=pHostEnt->ph_addr_list;

pIPAddPtr=*pIPAddPtr;

nIPNetAddr=*pIPAddPtr;

//nIPNetAddr=pIPAddPtr->nIPAddr;

pLocalIPName=inet_ntoa(nIPNetAddr);

szMYIPAddr=pLocalIPName->szIPAddr;

MessageBox(szMYIPAddr,INFORMATION);

WSACleanup();

exit;

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新脚本其他学习
    热门脚本其他学习
    脚本专栏子分类