InternetConnect



  • hallo,

    kann mir jemand sagen mit was ich die letzte variable fuellen muss, die dwContext variable...

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcewinet/html/cerefinternetconnect.asp

    ich blick da irgendwie nicht durch...





  • ich meine auch die InternetConnect funktion, oder habe ich das sample dafuer uebersehen?



  • Sry... konnte jetzt gerade net durchlesen was ich dir hier jetzt gebe... aber sollte das drin stehen was du brauchst 😉

    Using InternetConnect

    To begin a session, the InternetConnect function must create a handle off the root handle returned by the InternetOpen function. InternetConnect sets the server address, port number, user name, password, and type of service.

    InternetConnect uses the root HINTERNET handle created by InternetOpen to establish a session handle. If the INTERNET_FLAG_ASYNC flag was set in the call to InternetOpen, the call to InternetConnect should include a nonzero context value.

    The server name can contain either the host name (for example, "www.servername.com") or IP number of the site in ASCII dotted-decimal format (for example, "10.0.1.45").

    The server port is the Transmission Control Protocol/Internet Protocol (TCP/IP) port number to connect to on the server. InternetConnect uses the default port for the selected service type if the INTERNET_INVALID_PORT_NUMBER value is used. The following list contains the server port defaults for WinINet.

    Value Meaning
    INTERNET_DEFAULT_FTP_PORT Use the default port for ftp servers (port 21).
    INTERNET_DEFAULT_GOPHER_PORT Use the default port for gopher servers (port 70).
    INTERNET_DEFAULT_HTTP_PORT Use the default port for http servers (port 80).
    INTERNET_DEFAULT_HTTPS_PORT Use the default port for https servers (port 443).
    INTERNET_DEFAULT_SOCKS_PORT Use the default port for SOCKS firewall servers (port 1080).

    von: HTTP Sessions



  • This function opens an FTP or HTTP session for a specified site.

    HINTERNET WINAPI InternetConnect(
    HINTERNET hInternet,
    LPCTSTR lpszServerName,
    INTERNET_PORT nServerPort,
    LPCTSTR lpszUserName,
    LPCTSTR lpszPassword,
    DWORD dwService,
    DWORD dwFlags,
    DWORD dwContext
    );

    Parameters

    hInternet
    [in] Handle to the current Internet session. The handle must have been returned by a previous call to InternetOpen.
    lpszServerName
    [in] Long pointer to a null-terminated string that contains the host name of an Internet server. Alternately, the string can contain the IP number of the site in ASCII dotted-decimal format (for example, 11.0.1.45).
    nServerPort
    [in] Number of the TCP/IP port on the server to connect to. The following table shows the possible values. These flags set only the port that will be used. The service is set by the value of dwService.
    Value Description
    INTERNET_DEFAULT_FTP_PORT Uses the default port for FTP servers (port 21).
    INTERNET_DEFAULT_HTTP_PORT Uses the default port for HTTP servers (port 80).
    INTERNET_DEFAULT_HTTPS_PORT Uses the default port for HTTPS servers (port 443).
    INTERNET_DEFAULT_SOCKS_PORT Uses the default port for SOCKS firewall servers (port 1080).
    INTERNET_INVALID_PORT_NUMBER Uses the default port for the service specified by dwService.
    lpszUserName
    [in] Long pointer to a null-terminated string that contains the name of the user to log on. If this parameter is NULL, the function uses an appropriate default, except for HTTP; a NULL parameter in HTTP causes the server to return an error. For the FTP protocol, the default is "anonymous".
    lpszPassword
    [in] Long pointer to a null-terminated string that contains the password to use to log on. If both lpszPassword and lpszUserName are NULL, the function uses the default "anonymous" password. In the case of FTP, the default password is the user's e-mail name. If lpszPassword is NULL, but lpszUserName is not NULL, the function uses a blank password. The following table shows the behavior for the four possible settings of lpszUserName and lpszPassword.
    lpszUserName lpszPassword User name sent to FTP server Password sent to FTP server
    NULL NULL "anonymous" User's e-mail name
    Non-null string NULL lpszUserName ""
    NULL Non-null string ERROR ERROR
    Non-null string Non-null string lpszUserName lpszPassword
    dwService
    [in] Specifies the type of service to access. The following table shows the possible values. This parameter is one of these values.
    Value Description
    INTERNET_SERVICE_FTP FTP service.
    INTERNET_SERVICE_HTTP HTTP service.
    dwFlags
    [in] Flags specific to the service used. When the value of dwService is INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE causes the application to use passive FTP semantics.
    dwContext
    [in] Specifies the application-defined value that is used to identify the application context for the returned handle in callbacks.

    den fettgedruckten teil verstehe ich nicht und kann damit nichts anfagen...

    die OpenInternet geschichte ist klar, es geht mir auch nur um den letzten parameter: dwContext.
    ich versteh einfach nicht was damit gemeint ist.



  • if ((hFtp = InternetOpen(stream.str().c_str(), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, NULL)) == NULL)
    		return false;
    
    	if ((hFtp = InternetConnect(hFtp, host.sAddress.c_str(), INTERNET_DEFAULT_FTP_PORT, host.sUser.c_str(), host.sPW.c_str(), INTERNET_SERVICE_FTP, host.bPassiv ? INTERNET_FLAG_PASSIVE : 0, NULL)) == NULL) 
    		return false;
    

    Reicht das als Sample? 😃



  • das geht eben nicht ich kann dwContext nicht NULL setzen, einmal meckert der compiler:

    [Warning] passing arg 8 of `InternetConnectA' makes integer from pointer without a cast

    und dann auch noch getlasterror:

    12007



  • Dann setz ihr auf '0L'. 😃

    Was hast du denn fürn Compiler ?



  • aendert nichts an der sache...

    was heisst dieser abschnitt aus der msdn denn ueberhaupt, den ich ein paar posts weiter oben fett gedruckt habe?



  • ratloser schrieb:

    aendert nichts an der sache...

    Ach ne... :p

    ratloser schrieb:

    was heisst dieser abschnitt aus der msdn denn ueberhaupt, den ich ein paar posts weiter oben fett gedruckt habe?

    Hmm....
    "[in] Specifies the application-defined value that is used to identify the application context for the returned handle in callbacks."
    ➡ 💡
    Spezifiziert den Anwendungs-definierten Wert, der benutzt wird, um die Anwendung (bzw den Anwendungskontext, also dein Programm) in Funktionen mit der Aufrufkonvention 'Callback' (-> __stdcall) zu kennzeichnen.



  • ich habs nun geloest,

    damit andere nicht den selben bloeden fehler machen muessen:
    man darf kein 'ftp://' bei der angabe des ftp-servers machen 🙄 🙄



  • Danach hättest de nur fragen müssen... das ist klar ... was hat denn auch ftp:// mit dem Servernamen zu tun 😉


Anmelden zum Antworten