/* Written by jaron, 2002-07-15 */
/* Source: jiangdu Information Network Forum
Http://www.jiangdu.net/bbs;;*/
/* Indicate the source and retain the copyright information */
/* Welcome to SiteManager website management system
Http://sitemanager.cnzone.net;;*/
// File name: setup. rul
// Script Function: Obtain the TCP/IP address through the host name
// Written on:
// Usage: Call the fgetipaddress (szhost, szipadress) function)
// Written by jaron, 2002-07-15
// Original Source: jiangdu Information Network ForumHttp://www.jiangdu.net/bbs;;
// Indicate the source and retain the copyright information.
// Welcome to SiteManager website management systemHttp://sitemanager.cnzone.net;;
# Include "sddialog. H"
# Include "IPaddress. rul"
String szipaddress;
String szhostname;
Bool nresult;
Program
Sdshowdlgedit1 ("", "Enter your host name", "Host Name:", szhostname );
Nresult = fgetipaddress (szhostname, szipaddress );
If nresult then
MessageBox ("IP Address:" + szipaddress, information );
Endif;
Endprogram
# Include "sddialog. rul"
======================================
// File name: IPaddress. rul
// Script Function: Obtain the TCP/IP address through the host name
// Written on:
// Usage:
// 1. Add # include "IPaddress. rul" before setup. rul"
// 2. Call the fgetipaddress (szhost, szipadress) function)
// Written by jaron, 2002-07-15
// Original Source: jiangdu Information Network ForumHttp://www.jiangdu.net/bbs;;
// Indicate the source and retain the copyright information.
// Welcome to SiteManager website management systemHttp://sitemanager.cnzone.net;;
Prototype number wsock32.wsastartup (number, pointer );
Prototype number wsock32.gethostbyname (string );
Prototype number kernel32.rtlmovememory (pointer, number, number );
Prototype number wsock32.wsacleanup ();
Prototype fgetipaddress (string, byref string );
Typedef wsadata
Begin
Int wversion;
Int whighversion;
String szdescription [255];
String szsystemstatus [128];
Int imaxsockets;
Int imaxudpdg;
Int lpszvendorinfo;
End;
Typedef hostent
Begin
Number hname; // as long
Number haliases; // as long
Short haddrtype; // as integer
Short hlength; // as integer
Number haddrlist; // as long
End;
Typedef IPaddress
Begin
Char B1; // first
Char B2; // second
Char B3; // third
Char B4; // fourth
End;
Function fgetipaddress (szhost, szipadress)
Wsadata structwsadata;
Wsadata pointer pstructwsadata;
Hostent structhostent;
Hostent pointer pstructhostent;
Number nresult;
Number phostaddress;
Pointer phostipaddress;
Number hostipaddress;
IPaddress;
IPaddress pointer pipaddress;
String SB1, sb2, sb3, sb4;
Number nstartup;
Bool breturn;
Begin
If szhost = "" then
Return false;
Endif;
If usedll (winsysdir ^ "wsock32.dll") <0 then
Return false;
Endif;
Pstructwsadata = & structwsadata;
Pstructhostent = & structhostent;
Nstartup = wsastartup (0x101, pstructwsadata );
If nstartup! = 0 then
Return false;
Endif;
Phostaddress = gethostbyname (szhost );
If phostaddress! = 0 then
Rtlmovememory (pstructhostent, phostaddress, 16 );
Phostipaddress = & hostipaddress;
Rtlmovememory (phostipaddress, structhostent. haddrlist, 4 );
Pipaddress = & IPaddress;
Rtlmovememory (pipaddress, hostipaddress, 4 );
Numtostr (SB1, pipaddress-> B1 );
Numtostr (sb2, pipaddress-> B2 );
Numtostr (sb3, pipaddress-> B3 );
Numtostr (sb4, pipaddress-> B4 );
Szipadress = SB1 + "." + sb2 + "." + sb3 + "." + sb4;
Breturn = true;
Else
Breturn = false;
Endif;
If nstartup = 0 then
Wsacleanup ();
Endif;
Unusedll ("wsock32.dll ");
Return breturn;
End;