wininet error messages

This is a discussion on wininet error messages within the C++ Programming forums, part of the General Programming Boards category; I'm trying to find out how to get the extended information from a ftp server if the error that is ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    4

    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
    Last edited by tody4; 01-27-2006 at 01:31 PM. Reason: code re-alignment

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    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);

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    4
    Thanks for the reply. I'll test it on monday when the person remotely is available.

    Have a great weekend.

  4. #4
    Registered User
    Join Date
    Jan 2006
    Posts
    4

    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?

  5. #5
    Registered User
    Join Date
    Jan 2006
    Posts
    4

    Nevermind

    I found the error. Thanks for the help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. wininet
    By jopp3 in forum C Programming
    Replies: 0
    Last Post: 04-29-2007, 09:27 AM
  2. My tut on WinINet...
    By Queatrix in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 04-24-2007, 11:33 AM
  3. Using wininet with cookies
    By bithub in forum Windows Programming
    Replies: 4
    Last Post: 06-01-2006, 10:10 PM
  4. wininet (internetconnect)
    By jabroni77 in forum Networking/Device Communication
    Replies: 0
    Last Post: 05-19-2005, 07:29 AM
  5. Where can i find a tutorial on WinInet?
    By Inquirer in forum C++ Programming
    Replies: 1
    Last Post: 04-24-2002, 04:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21