-
wininet error messages
I'm trying to find out how to get the extended information from a ftp server if the error that is returned is 12003. I know that I'm supposed to use the internetgetlastresponseinfo function, but I don't know how to handle the string that is returned. Here is the code segment that deals with this.
Code:
DWORD errNo = 0,
errSize = 0;
CString errDesc = "";
...
errNo = GetLastError();
switch(errNo)
{
case 0:
printf("No error found"); break;
case 12003:
{
InternetGetLastResponseInfo(&errNo, (LPTSTR) &errDesc, &errSize);
printf("Error 12003\nExtended information:\n%s\n", errDesc);
break;
}
case 12031:
printf("Server was busy, please try again later");
break;
case 12007:
printf("Firewall blocking connection to ftp server, please unblock and try again");
break;
default:
break;
}
TIA
-
Well that's what indescriminate casting will get you.
BOOL InternetGetLastResponseInfo(
LPDWORD lpdwError,
LPTSTR lpszBuffer,
LPDWORD lpdwBufferLength
);
> InternetGetLastResponseInfo(&errNo, (LPTSTR) &errDesc, &errSize);
Simply mushing things into the correct type doesn't make the code magically work.
Try something like this perhaps
Code:
TCHAR buff[1000];
DWORD bSize = 1000;
DWORD error;
InternetGetLastResponseInfo(&error, buff, &bSize);
-
Thanks for the reply. I'll test it on monday when the person remotely is available.
Have a great weekend.
-
TCHAR issue
I can't seem to declare a variable as a type of TCHAR. I've tried to include Windows.h (can't do that because of the afxinet.h include), and tried to include tchar.h to no avail. Is there something that I'm supposed to include that will allow me to use the TCHAR type?
-
Nevermind
I found the error. Thanks for the help.