InternetSetStatusCallback...

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
popstatic
Messages : 83
Inscription : lun. 20/sept./2004 18:21
Localisation : derriere toi fais gaffe!

InternetSetStatusCallback...

Message par popstatic »

Bonjour à tous!

afin d'avoir une progression d'upload par FTP (j'utilise l'API FtpPutFile_ ) msdn indique qu'il faut utiliser l'API InternetSetStatusCallback

en fait d'après ce que j'ai compris, il faut appeller InternetSetStatusCallback en lui passant en paramètre le handle de connexion (jusqu'ici tout va bien) et l'adresse de ma fonction PB qui doit etre appellée à chaque évenement. Apparement ma fonction PB doit respecter une certaine forme, au niveau de ses paramètres (tiré aussi de msdn):
InternetStatusCallback

Prototype for an application-defined status callback function.

The INTERNET_STATUS_CALLBACK type defines a pointer to this callback function.InternetStatusCallback is a placeholder for the application-defined function name.

void CALLBACK InternetStatusCallback(
HINTERNET hInternet,
DWORD_PTR dwContext,
DWORD dwInternetStatus,
LPVOID lpvStatusInformation,
DWORD dwStatusInformationLength
);

Parameters

hInternet
[in] The handle for which the callback function is called.
dwContext
[in] A pointer to a variable that specifies the application-defined context value associated with hInternet.
dwInternetStatus
[in] A status code that indicates why the callback function is called. This parameter can be one of the following values.
Value Meaning
INTERNET_STATUS_CLOSING_CONNECTION Closing the connection to the server. The lpvStatusInformation parameter is NULL.
INTERNET_STATUS_CONNECTED_TO_SERVER Successfully connected to the socket address (SOCKADDR) pointed to by lpvStatusInformation.
INTERNET_STATUS_CONNECTING_TO_SERVER Connecting to the socket address (SOCKADDR) pointed to by lpvStatusInformation.
INTERNET_STATUS_CONNECTION_CLOSED Successfully closed the connection to the server. The lpvStatusInformation parameter is NULL.
INTERNET_STATUS_COOKIE_HISTORY Retrieving content from the cache. Contains data about past cookie events for the URL such as if cookies were accepted, rejected, downgraded, or leashed.

The lpvStatusInformation parameter is a pointer to an InternetCookieHistory structure.
INTERNET_STATUS_COOKIE_RECEIVED Indicates the number of cookies that were accepted, rejected, downgraded (changed from persistent to session cookies), or leashed (will be sent out only in 1st party context). The lpvStatusInformation parameter is a DWORD with the number of cookies received.
INTERNET_STATUS_COOKIE_SENT Indicates the number of cookies that were either sent or suppressed, when a request is sent. The lpvStatusInformation parameter is a DWORD with the number of cookies sent or suppressed.
INTERNET_STATUS_CTL_RESPONSE_RECEIVED Not implemented.
INTERNET_STATUS_DETECTING_PROXY Notifies the client application that a proxy has been detected.
INTERNET_STATUS_HANDLE_CLOSING This handle value has been terminated.
INTERNET_STATUS_HANDLE_CREATED Used by InternetConnect to indicate it has created the new handle. This lets the application call InternetCloseHandle from another thread, if the connect is taking too long. The lpvStatusInformation parameter contains the address of an INTERNET_ASYNC_RESULT structure.
INTERNET_STATUS_INTERMEDIATE_RESPONSE Received an intermediate (100 level) status code message from the server.
INTERNET_STATUS_NAME_RESOLVED Successfully found the IP address of the name contained in lpvStatusInformation.
INTERNET_STATUS_P3P_HEADER The response has a P3P header in it.
INTERNET_STATUS_P3P_POLICYREF Not implemented.
INTERNET_STATUS_PREFETCH Not implemented.
INTERNET_STATUS_PRIVACY_IMPACTED Not implemented.
INTERNET_STATUS_RECEIVING_RESPONSE Waiting for the server to respond to a request. The lpvStatusInformation parameter is NULL.
INTERNET_STATUS_REDIRECT An HTTP request is about to automatically redirect the request. The lpvStatusInformation parameter points to the new URL. At this point, the application can read any data returned by the server with the redirect response and can query the response headers. It can also cancel the operation by closing the handle. This callback is not made if the original request specified INTERNET_FLAG_NO_AUTO_REDIRECT.
INTERNET_STATUS_REQUEST_COMPLETE An asynchronous operation has been completed. The lpvStatusInformation parameter contains the address of an INTERNET_ASYNC_RESULT structure.
INTERNET_STATUS_REQUEST_SENT Successfully sent the information request to the server. The lpvStatusInformation parameter points to a DWORD value that contains the number of bytes sent.
INTERNET_STATUS_RESOLVING_NAME Looking up the IP address of the name contained in lpvStatusInformation.
INTERNET_STATUS_RESPONSE_RECEIVED Successfully received a response from the server. The lpvStatusInformation parameter points to a DWORD value that contains the number, in bytes, received.
INTERNET_STATUS_SENDING_REQUEST Sending the information request to the server. The lpvStatusInformation parameter is NULL.
INTERNET_STATUS_STATE_CHANGE Moved between a secure (HTTPS) and a nonsecure (HTTP) site. The user must be informed of this change; otherwise, the user is at risk of disclosing sensitive information involuntarily. When this flag is set, the lpvStatusInformation parameter points to a status DWORD that contains additonal flags.
lpvStatusInformation
[in] A pointer to additional status information. When the INTERNET_STATUS_STATE_CHANGE flag is set, lpvStatusInformation points to a DWORD that contains one or more of the following flags:
Value Meaning
INTERNET_STATE_CONNECTED Connected state. Mutually exclusive with disconnected state.
INTERNET_STATE_DISCONNECTED Disconnected state. No network connection could be established.
INTERNET_STATE_DISCONNECTED_BY_USER Disconnected by user request.
INTERNET_STATE_IDLE No network requests are being made by Windows Internet.
INTERNET_STATE_BUSY Network requests are being made by Windows Internet.
INTERNET_STATUS_USER_INPUT_REQUIRED The request requires user input to be completed.
dwStatusInformationLength
[in] The size, in bytes, of the data pointed to by lpvStatusInformation.

Return Values
This callback function does not return a value.
bref j'ai un mal fou a faire marcher tout ça, FtpPutFile_ fonctionne mais impossible de faire marcher le callback.... ça fait longtemps que je patauge, et impossible de trouver sur google des exemples d'implémentation de InternetSetStatusCallback_ avec FtpPutFile_.

J'en ai hélas vraiment besoin et je lance donc un "a l'aide!"


merci d'avance pour votre aide,

PS: ci joint mon code tout simple avec l'api windows

Code : Tout sélectionner

Procedure.l FTPInit()
  ProcedureReturn InternetOpen_("FTP",1,"","",0)
EndProcedure


Procedure.l FTPConnect(hInternet,Server.s,User.s,Password.s,Port.l)
  ProcedureReturn InternetConnect_(hInternet,Server,Port,User,Password,1,0,0)
EndProcedure


Procedure.l FTPDir(hConnect.l)
  hFind=FtpFindFirstFile_(hConnect,"*.*",@FTPFile.WIN32_FIND_DATA,0,0)
  If hFind
    Find=1
    Debug PeekS(@FTPFile\cFileName)
    While Find
      Find=InternetFindNextFile_(hFind,@FTPFile)
      If Find
        Debug PeekS(@FTPFile\cFileName)
      EndIf     
    Wend
  EndIf
EndProcedure


Procedure.l FTPSetDir(hConnect.l,Dir.s)
  ProcedureReturn FtpSetCurrentDirectory_(hConnect,Dir)
EndProcedure


Procedure.l FTPCreateDir(hConnect.l,Dir.s)
  ProcedureReturn FtpCreateDirectory_(hConnect,Dir)
EndProcedure


Procedure.l FTPDownload(hConnect.l,Source.s,Dest.s)
  ProcedureReturn FtpGetFile_(hConnect,Source,Dest,0,0,0,0)
EndProcedure


Procedure.l FTPUpload(hConnect.l,Source.s,Dest.s)
  ProcedureReturn FtpPutFile_(hConnect,Source,Dest,0,0)
EndProcedure


Procedure.l FTPClose(hInternet.l)
  ProcedureReturn InternetCloseHandle_(hInternet)
EndProcedure


Procedure FtpCallBack(hInternet.l,hConnect.l,lpvStatusInformation.l,dwStatusInformationLength.l)
  Debug 1
EndProcedure


;--------------------
hInternet=FTPInit()
If hInternet
  hConnect=FTPConnect(hInternet,"adresse","login","password",21)
  If hConnect
   
    FTPSetDir(hConnect,"/")
    FTPDir(hConnect)
    InternetSetStatusCallback_(hConnect,@FtpCallBack());
    FTPUpload(hConnect,"fichiersource","fichierdestination")
    FTPClose(hInternet)
  EndIf
EndIf
End 
Asus bien? asus tres bien!