Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetLastError does not return err code from InternetConne
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00916056
Message ID:
00916323
Vues:
7
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform