Exemple de code pour WINSOCK dans InstallShield_Other

2019-12-27
Dans l'exemple suivant, InstallShield peut utiliser WINSOCK pour obtenir une adresse IP. Le fichier suivant peut être enregistré sous 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 BR> end;
WSAData structWSAData;
WSAData POINTER pWSAData;
typedef HostEnt
begin
POINTER nom_ph;
POINTER ph_aliases;
short h_addrtype;
short h_length;
POINTER ph_addr_list;
end;
HostEnt structHostEnt;
HostEnt POINTER pHostEnt;
SHORT nlen;
NUMBER nIPNetAddr;
NUMBER nVersio n;
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 (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;
nIPNet * pIPAddPtr;
// nIPNetAddr = pIPAddPtr-> nIPAddr;
pLocalIPName = inet_ntoa (nIPNetAddr);
szMYIPAddr = pLocalIPName-> szIPAddr;
MessageBox (szMYIPAddr, INFORMATION);
WS );
quitter;
www.xd1998.com@2001-2030Partage De Technologie