CInternetSession::OpenURL liefert keinen CHttpFile* zurück!



  • In der MSDN steht:
    CInternetSession::OpenURL
    CStdioFile
    OpenURL( LPCTSTR pstrURL, DWORD dwContext = 1, DWORD dwFlags = INTERNET_FLAG_TRANSFER_ASCII, LPCTSTR pstrHeaders = NULL, DWORD dwHeadersLength = 0 );
    Throw ( CInternetException );

    Return Value

    Returns a file handle for FTP, GOPHER, HTTP, and FILE-type Internet services only. Returns NULL if parsing was unsuccessful.

    The pointer that OpenURL returns depends on pszURL’s type of service. The table below illustrates the possible pointers OpenURL can return.

    URL type Returns
    file:// CStdioFile*
    http:// CHttpFile*
    gopher:// CGopherFile*
    ftp:// CInternetFile**

    Wenn ich jetzt mit

    CInternetSession InternetSession;
    CString URL = "http://www.gmx.de";
    CHttpFile* HttpFile = InternetSession.OpenURL(URL);
    

    das versuche klappt das nicht! Ich muss die letzte Zeile so schreiben:

    CStdioFile* StdioFile = InternetSession.OpenURL(URL);
    

    Aber ich brauche ein CHttpFile*, weil ich von der Seite dann mit QueryInfoStatusCode den Status abfragen möchte! Ich schreibe so etwas wie einen Link Checker!



  • Versuch's mal damit:

    CInternetSession pInetSession;
    CStdioFile*      pNetFile;
    CString          sURL = "http://www.gmx.de";
    
    try
    {
       pNetFile = pInetSession.OpenURL(sURL , 1, INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_RELOAD);
    }
    

    Kannst dann bei Bedarf auch noch per catch die mgl. Fehler abfangen.
    Außerdem steht in den FAQ noch ein Beitrag... 😉

    Happosai

    [edit]verlsen... 🙄 [/cpp]

    [ Dieser Beitrag wurde am 23.11.2002 um 20:37 Uhr von Happosai editiert. ]



  • Jetzt habe ich doch trotzdem nur ein CStdioFile*! Ich brauche aber ein CHttpFile*!



  • Ich Idiot!!! :o
    Das Ding ist doch abgeleitet!
    Also geht:

    HttpFile = (CHttpFile*) InternetSession.OpenURL(URL);
    

    🕶


Anmelden zum Antworten