Quote for Winsock in InstallShield

zhaozj2021-02-16  45

/ * Written by Jaron, 2002-08-15 * /

/ * Reprinted please indicate the source and keep this copyright information * /

/ * Welcome to SiteManager Website Management System

http://sitemanager.cnzone.net; * /

With the following example, InstallShield can use Winsock to get the IP address, save the following file as 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 hostentbegin pointer pH_Name; POINTER PH_ALIASES; Short H_ADDRTYPE; Short H_LENGTH; POINTER PH_ADDR_LIST; End; Hostent Structure; Hostent Pointer Phostent; Short Nlen; Nlen;

Number NVersion; String Szdefault; string szurl; string szpath; number nrc; number nrc2; string szhostname; string szmyipaddr; pointer pwinsockreturn;

Typedef ipname begin string szipaddr [100]; end; ipname localpan; ipname Pointer Plocalipname

Typedef ipaddrlist begin Pointer Pipaddr; end; ipaddrlist structipaddrlist; ipaddrlist pointer pipaddrlist;

TypeDef ipaddptr begin long Nipaddr; end; ipaddptr structure; 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 ();

Programpwsadata = & 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;

转载请注明原文地址:https://www.9cbs.com/read-27148.html

New Post(0)