/*************************************** * ******************************** // * Function description: get the current Internet IP Address/* parameter: NONE/* return value: Return Internet IP address, cstring string/*: koma 2009.08.21 /************************************ * **********************************/cstring cqdlg:: getipaddress () {char Buf [max_path] = {0}; char chtempip [128]; char chip [64]; cstring strpath; strpath = getexepath () + "\ netip. ini "; urldownloadtof Ile (0, "http://www.ip138.com/ip2city.asp", strpath, 0, null); file * fp = fopen (strpath, "R"); If (FP! = NULL) {fseek (FP, 0, seek_set); fread (BUF, 1,256, FP); fclose (FP); char * iindex = strstr (BUF ,"["); if (iindex) {sprintf (chtempip, "% s", iindex); int nbuflen = strlen (chtempip); For (INT I = 0; I <nbuflen; I ++) {chip [I] = chtempip [I + 1]; If (chtempip [I] = ']') {chip [I-1] = '\ 0 '; deletefile (strpath); Continue ;}}} cstring strtemp = ""; if (chip! = "") {Strtemp. format ("% s", Chip);} return strtemp ;} /*************************************** * ******************************** // * function description: get the current host name/* parameter: NONE/* return value: Return host name, cstring type string/*: koma 2009.08.21 /************************************ * **********************************/cstring cqdlg:: gethostname () {word wversionrequested; wsadata; int err; wversionrequested = makeword (2, 0 ); Err = wsastartup (wversionrequested, & wsadata); If (Err! = 0) {return err;} If (lobyte (wsadata. wversion! = 2) | hibyte (wsadata. wversion )! = 0) {wsacleanup (); Return (char) wsavernotsupported;} Char szhostname [256]; int nretcode; cstring STR = ""; // call the API to obtain the host name nretcode = gethostname (szhostname, sizeof (szhostname); If (nretcode! = 0) {return wsagetlasterror ();} If (szhostname! = "") {Str. Format ("Host Name: % s", szhostname) ;}return STR ;}