Skip to content

Latest commit

 

History

History
53 lines (37 loc) · 1.33 KB

sample_109.md

File metadata and controls

53 lines (37 loc) · 1.33 KB

Home

Wininet last error description

Code:

#DEFINE ERROR_INSUFFICIENT_BUFFER   122

	DECLARE SHORT InternetGetLastResponseInfo IN wininet;
		INTEGER @ lpdwError,;
		STRING  @ lpszBuffer,;
		INTEGER @ lpdwBufferLength

	DECLARE INTEGER GetLastError IN kernel32

	LOCAL lpdwError, lpdwBufferLength, lpszBuffer, lnResult

	lpdwError = 0
	lpdwBufferLength = 250
	lpszBuffer = SPACE(lpdwBufferLength)
	
	lnResult = InternetGetLastResponseInfo (@lpdwError,;
			@lpszBuffer, @lpdwBufferLength)

	IF lnResult = 0 And GetLastError() = ERROR_INSUFFICIENT_BUFFER
		lpszBuffer = SPACE(lpdwBufferLength)
		lnResult = InternetGetLastResponseInfo (@lpdwError,;
				@lpszBuffer, @lpdwBufferLength)
	ENDIF

	IF lnResult = 1
		? "Error:", lpdwError
		? "Message:", LEFT(lpszBuffer, lpdwBufferLength)
	ELSE
		? "No response is available"
	ENDIF
RETURN  

Listed functions:

GetLastError
InternetGetLastResponseInfo

Comment:

This procedure retrieves the last Microsoft® Win32® Internet function error description or server response on the thread calling it.

Do not expect any valid response of this function unless you have a connection to a server.