As mentioned in the previous chapter, you can dynamically obtain the Host Name and Internet IP address under VC. If you are interested, see it!
/*************************************** *******************************/<Br/> /* function Description: obtain the current Internet IP address <br/>/* parameter: None <br/>/* return value: Return Internet IP address, cstring type string <br/>/*: koma 2009.08.21 <br/> /******************************** **************************************** /<br/> cstring cqdlg:: getipaddress () <br/>{< br/> char Buf [max_path] ={ 0 }; <br/> char chtempip [128]; <br/> char chip [64]; <br/> cstring STRP Ath; <br/> strpath = getexepath () + "// netip. ini "; <br/> urldownloadtofile (0," http://www.ip138.com/ip2city.asp ", strpath, 0, null); </P> <p> file * fp = fopen (strpath, "R"); <br/> If (FP! = NULL) <br/>{< br/> fseek (FP, 0, seek_set); <br/> fread (BUF, 1,256, FP ); <br/> fclose (FP); <br/> char * iindex = strstr (BUF, "["); <br/> If (iindex) <br/>{< br/> sprintf (chtempip, "% s", iindex); <br/> int nbuflen = strlen (chtempip ); <br/> for (INT I = 0; I <nbuflen; I ++) <br/> {<br/> chip [I] = chtempip [I + 1]; </P> <p> If (chtempip [I] = ']') <br/> {<br/> chip [I-1] = '/0 '; <br/> deletefile (strpath); <br/> Continue; <br/>}< br/> cstring strtemp = ""; <br/> If (chip! = "") <Br/>{< br/> strtemp. format ("% s", Chip); <br/>}< br/> return strtemp; <br/>}</P> <p> /*************************** **************************************** * *****/<br/>/* function description: get the current host name <br/>/* parameter: None <br/>/* return value: Return host name, cstring type string <br/>/*: koma 2009.08.21 <br/> /******************************** **************************************** /<br/> cstring cqdlg:: gethostname () <br/>{< br/> word WV Ersionrequested; <br/> wsadata; <br/> int err; <br/> wversionrequested = makeword (2, 0); <br/> err = wsastartup (wversionrequested, & wsadata); <br/> If (Err! = 0) <br/>{< br/> return err; <br/>}< br/> If (lobyte (wsadata. wversion! = 2) | hibyte (wsadata. wversion )! = 0) <br/>{< br/> wsacleanup (); <br/> return (char) wsavernotsupported; <br/>}</P> <p> char szhostname [256]; <br/> int nretcode; <br/> cstring STR = ""; </P> <p> // call an API to obtain the host name <br/> nretcode = gethostname (szhostname, sizeof (szhostname); <br/> If (nretcode! = 0) <br/>{< br/> return wsagetlasterror (); <br/>}< br/> If (szhostname! = "") <Br/>{< br/> Str. format ("Host Name: % s", szhostname); <br/>}< br/> return STR; <br/>}