* GetNicID - uses Win-32 API call to get NIC ID (physical address) * this is the DLL declaration to access the API method DECLARE INTEGER GetAdaptersInfo IN iphlpapi ; STRING @pAdapterInfo, LONG @pOutBufLen LOCAL lcBuffer, lnBufsize lnBufsize = 0 lcBuffer = "" * first call to GetAdaptorsInfo() method * this call usually returns: ERROR_BUFFER_OVERFLOW (111) * with lnBufsize set to the required amount of memory = GetAdaptersInfo(@lcBuffer, @lnBufsize) * build buffer string from nulls lcBuffer = Repli(Chr(0), lnBufsize) * call method again IF GetAdaptersInfo(@lcBuffer, @lnBufsize) <> 0 && ERROR_SUCCESS * no joy =MESSAGEBOX('WinAPI problem - GetAdaptorsInfo') RETURN ENDIF LOCAL lcNICName, lnAddrlen, lcAddress, ii, lcIntraIP, lcMask, lcGateway * lcNICName is between {} lcNICName = STREXTRACT(lcBuffer,"{","}",1,4) * 401st byte of lcBuffer is size of NIC address string lnAddrlen = Asc(SUBSTR(lcBuffer, 401, 1)) * actual NIC address starts at byte 405 of lcBuffer lcAddress = SUBSTR(lcBuffer, 405, lnAddrlen) lcIntraIP = allt(SUBSTR(lcBuffer,433,15)) lcMask = allt(SUBSTR(lcBuffer,449,15)) lcGateway = allt(SUBSTR(lcBuffer,473,15)) * build decimal and hex strings from ASCII values of returned characters lcThisID = '' lcThisHex = '' FOR ii = 1 TO lnAddrLen lcThisID = lcThisID + ; IIF(ii>1,',','') + ; ALLTRIM(STR(ASC(SUBSTR(lcAddress,ii,1)))) lcThisHex = lcThisHex + ; IIF(ii>1,'-','') + ; RIGHT(TRANSFORM(ASC(SUBSTR(lcAddress,ii,1)),'@0'),2) NEXT * display decimal and hex versions of NIC ID ? ? 'NIC Name (chr) : '+lcNICName ? 'NIC ID (decimal): '+lcThisID ? 'NIC ID (hex) : '+ lcThisHex ? 'NIC IntraIP : '+ lcIntraIP ? 'NIC Mask : '+ lcMask ? 'NIC Gateway : '+ lcGateway Clear DLLS GetAdaptersInfo>Hi all
LOCAL lcRetVal, loIE, loDoc, lnTimeOut, lnTSec, lnST, lnFH, lcFL, ; > lnX, lcIP, lnCtr > > >WAIT WINDOW "Detecting Internet IP address ..." NOWAIT > > >DECLARE Sleep IN kernel32 INTEGER millisec > > >loIE = CREATEOBJECT('internetexplorer.application') >loIE.Silent = .T. && no dialogs > >lcIP = "" >lnTimeOut = 20 >lnTSec = SECONDS() > >loIE.navigate2("www.whatismyip.com") > >lnCtr = 0 > > >*-------------------------------------------- >* wait until complete >*-------------------------------------------- >lnST = SECONDS() > >Sleep(50) > > >DO WHILE .T. > IF NOT VERSION(5) = 700 > *** In 7.0, the DoEvents behavior changed to stop and wait for event. > *** In 8.0, the behavior was changed back to 6.0 behavior. > DOEVENTS > ENDIF > > > DO CASE > CASE loIE.ReadyState = 4 AND NOT loIE.Busy > EXIT > > CASE loIE.ReadyState = 3 AND SECONDS() - lnST > 5 > EXIT > > CASE SECONDS() - lnST > lnTimeOut > EXIT > ENDCASE > > > lnCtr = lnCtr + 1 > > WAIT WINDOW "Detecting Internet IP address (" + ALLTRIM(STR(lnCtr)) + ") ..." NOWAIT > > > Sleep(50) >ENDDO > > >**** >**** This IF condition is a major cause of the problem, I have tried VARTYPE() also as well as the below conditions independently, no joy >**** >IF TYPE("loIE.DOCUMENT") = "O" AND TYPE("loIE.DOCUMENT.NAME") = "C" > *** 21/02/2007 put in a TRY-CATCH for when object is created > *** but innertext is invalid > TRY > loDoc = loIE.DOCUMENT > > *** now you have your doc. object in loDoc > MyString = loDoc.Body.InnerText &&& now you have a string with the contents > MyHTML = loDoc.Body.InnerHTML &&& same, but in HTML > > STRTOFILE(MyString, "InnerText.txt") > STRTOFILE(MyHTML , "InnerHTML.htm") > > > lnFH = FOPEN("InnerText.txt") > > DO WHILE NOT FEOF(lnFH) > lcFL = UPPER(FGETS(lnFH)) > > > DO CASE > CASE lcFL = UPPER("Your IP is ") > lcIP = ALLTRIM(STRTRAN(lcFL, UPPER("Your IP is "), "")) > EXIT > > CASE lcFL = UPPER("Your IP - ") > lcIP = ALLTRIM(STRTRAN(lcFL, UPPER("Your IP - "), "")) > EXIT > > CASE lcFL = UPPER("Bookmark Your IP - ") > lcIP = ALLTRIM(STRTRAN(lcFL, UPPER("Bookmark Your IP - "), "")) > EXIT > > CASE lcFL = UPPER("Bookmark Your IP Is ") > lcIP = ALLTRIM(STRTRAN(lcFL, UPPER("Bookmark Your IP Is "), "")) > EXIT > ENDCASE > ENDDO > > = FCLOSE(lnFH) > > > DELETE FILE InnerText.txt > DELETE FILE InnerHTML.htm > > > CATCH > lcIP = "" > ENDTRY >ENDIF > > >lcRetVal = IIF(EMPTY(lcIP), "Not detected", lcIP) > > >WAIT WINDOW "Internet IP address: " + lcRetVal + " ..." NOWAIT > > >CLEAR DLLS Sleep > > >RETURN lcRetVal