Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GetLastError does not return err code from InternetConne
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00916056
Message ID:
00916323
Views:
8
Hi Anatoliy,

I used the InternetGetLastResponseInfo API but it still does not return an error code. Even If I try to connect to the net and there is not internet connection I still get no error code. I have added some of my code. Perhaps I am doing something wrong:

This code is normally in a class

* Agent = Visual FoxPro

* ConnectNet Method
THIS.InternetHandle = InternetOpen((THIS.Agent), INTERNET_OPEN_TYPE_DIRECT, lcNULL, lcNULL, 0)
THIS.GetExtendedError()

*!* Check if internet connection could be made
IF THIS.InternetHandle = 0
THIS.CloseConnection()
RETURN .F.
ELSE
lcport = '21'
THIS.ConnectionHandle = InternetConnect(THIS.InternetHandle, (THIS.host), VAL(lcPort), ;
(THIS.UserName), (THIS.userPwd), INTERNET_SERVICE_FTP, 0, 0)
THIS.GetExtendedError()

IF THIS.ConnectionHandle = 0
THIS.CloseConnection()
THIS.GetErrorCode()
RETURN .F.
ENDIF

RETURN .T.




* Get Extended Error Method
LOCAL lcMessage, lnError, lcBuffer

THIS.ResultCode = GetLastError()

lnError = 0
lcBuffer = SPACE(MAX_PATH)

InternetGetLastResponseInfo(@lnError, @lcBuffer, MAX_PATH)

THIS.ExtendedResult = lnError
THIS.ExtendedMessage = LEFT(lcBuffer, AT(lcNULL, lcBuffer) - 1)

RETURN



* GetErrorCode Method
LOCAL lcMessage

IF THIS.ShowMessage
*!* Build Error Message Here
lcMessage = "Error (" + ALLTRIM(STR(THIS.ResultCode)) + ") - " + ;
THIS.GetErrorText(THIS.ResultCode)
IF !EMPTY(THIS.ExtendedMessage)
lcMessage = lcMessage + CHR(13) + CHR(13) + "Extended Error Info - (" + ;
ALLTRIM(STR(THIS.ExtendedResult)) + ;
") - " + THIS.ExtendedMessage
ENDIF

MESSAGEBOX(lcMessage, 48, "FTP Error Message")
ENDIF

RETURN THIS.ResultCode
Stuart Reid

True nobility lies not in being superior to another man, but in being superior to one’s previous self
Previous
Reply
Map
View

Click here to load this message in the networking platform