相思资源网 Design By www.200059.com
通过以下示例,InstallShield可以用WINSOCK获取IP地址,可将以下文件保存为tcpip.rul
#define WSADESCRIPTION_LEN 256
#define WSASYS_STATUS_LEN 128
typedef
WSAData
begin
INT wVersion;
INT wHighVersion;
char szDescription[WSADESCRIPTION_LEN+1];
char szSystemStatus[WSASYS_STATUS_LEN+1];
short iMaxSockets;
short iMaxUdpDg;
POINTER lpVendorInfo;
end;
WSAData structWSAData;
WSAData POINTER pWSAData;
typedef HostEnt
begin
POINTER ph_name;
POINTER ph_aliases;
short h_addrtype;
short h_length;
POINTER ph_addr_list;
end;
HostEnt structHostEnt;
HostEnt POINTER pHostEnt;
SHORT nlen;
NUMBER nIPNetAddr;
NUMBER nVersion;
STRING szMsg;
STRING szDefault;
STRING szURL;
STRING szPath;
NUMBER nRC;
NUMBER nRC2;
STRING szHostName;
STRING szMYIPAddr;
POINTER pWinSockReturn;
typedef IPName
begin
STRING szIPAddr[100];
end;
IPName LocalIPName;
IPName POINTER pLocalIPName;
typedef IPAddrList
begin
POINTER pIPAddr;
end;
IPAddrList structIPAddrList;
IPAddrList POINTER pIPAddrList;
typedef IPAddPtr
begin
LONG nIPAddr;
end;
IPAddPtr structIPAddPtr;
IPAddPtr POINTER pIPAddPtr;
POINTER pIN_Addr_Struct;
prototype POINTER wsock32.gethostbyname(BYREF STRING);
prototype POINTER wsock32.gethostname(BYREF STRING, NUMBER);
prototype POINTER wsock32.WSAStartup(INT, POINTER);
prototype POINTER wsock32.inet_ntoa( NUMBER);
prototype POINTER wsock32.WSACleanup();
prototype int wsock32.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;
#define WSADESCRIPTION_LEN 256
#define WSASYS_STATUS_LEN 128
typedef
WSAData
begin
INT wVersion;
INT wHighVersion;
char szDescription[WSADESCRIPTION_LEN+1];
char szSystemStatus[WSASYS_STATUS_LEN+1];
short iMaxSockets;
short iMaxUdpDg;
POINTER lpVendorInfo;
end;
WSAData structWSAData;
WSAData POINTER pWSAData;
typedef HostEnt
begin
POINTER ph_name;
POINTER ph_aliases;
short h_addrtype;
short h_length;
POINTER ph_addr_list;
end;
HostEnt structHostEnt;
HostEnt POINTER pHostEnt;
SHORT nlen;
NUMBER nIPNetAddr;
NUMBER nVersion;
STRING szMsg;
STRING szDefault;
STRING szURL;
STRING szPath;
NUMBER nRC;
NUMBER nRC2;
STRING szHostName;
STRING szMYIPAddr;
POINTER pWinSockReturn;
typedef IPName
begin
STRING szIPAddr[100];
end;
IPName LocalIPName;
IPName POINTER pLocalIPName;
typedef IPAddrList
begin
POINTER pIPAddr;
end;
IPAddrList structIPAddrList;
IPAddrList POINTER pIPAddrList;
typedef IPAddPtr
begin
LONG nIPAddr;
end;
IPAddPtr structIPAddPtr;
IPAddPtr POINTER pIPAddPtr;
POINTER pIN_Addr_Struct;
prototype POINTER wsock32.gethostbyname(BYREF STRING);
prototype POINTER wsock32.gethostname(BYREF STRING, NUMBER);
prototype POINTER wsock32.WSAStartup(INT, POINTER);
prototype POINTER wsock32.inet_ntoa( NUMBER);
prototype POINTER wsock32.WSACleanup();
prototype int wsock32.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;
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无在InstallShield中引用WINSOCK 的示例代码的评论...