Reference Winsock in InstallShield For example code _ other

Source: Internet
Author: User
The following example allows InstallShield to obtain an IP address using Winsock, which saves the following files 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 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.