Callback *bug* or is me?

Windows specific forum
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Callback *bug* or is me?

Post by Inner »

When it trys to set the call back procedure it always returns 0, failure.

AFAIK, I've done what is needed acording to the MSDN

Code: Select all

;- Roughton Design --- Source Header --------------------------------------------------------------
;
; Author:
; Purpose:
; Filename:
;
;--------------------------------------------------------------------------------------------------
;->
#INTERNET_SERVICE_FTP=1 
#INTERNET_OPEN_TYPE_DIRECT=1 
#FTP_TRANSFER_ASCII=1 
#FTP_TRANSFER_BINARY=2 

;-> 
Structure FTP
    server.s
    username.s
    password.s
    remotefile.s
    localfile.s
    port.l
    proxyname.s
    proxybypass.s    
EndStructure
Global sessionftp.FTP
;--------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------
Procedure InternetStatusCallback(hInternet.l,Context.l,InternetStatus.l,StatusInformation.l,StatusInformationLength.l)
    Debug("!")
EndProcedure
;--------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------
Procedure FTPGetFile()
    proxyname.s=sessionftp\proxyname
    proxybypass.s=sessionftp\proxybypass
    server.s=sessionftp\server
    port=sessionftp\port
    username.s=sessionftp\username
    password.s=sessionftp\password
    remotefile.s=sessionftp\remotefile
    localfile.s=sessionftp\localfile
        
    hInternet=InternetOpen_("FTP",#INTERNET_OPEN_TYPE_DIRECT,proxyname,proxybypass,0) 
    If(hInternet<>0)
        hCallback=InternetSetStatusCallback_(hInternet,@InternetStatusCallback())
        If(hCallback<>0)
            hConnect=InternetConnect_(hInternet,server,port,username,password,#INTERNET_SERVICE_FTP,0,0)
            If(hConnect<>0)
                If(FtpGetFile_(hConnect,remotefile,localfile,#FALSE,#FILE_SHARE_WRITE,#FTP_TRANSFER_BINARY,0)=#FALSE)
                    Debug("Error Obtaining File!")
                Else
                    Debug("Success!")
                EndIf
            Else
            EndIf
        Else
            Debug("Callback Failed!")
        EndIf
    EndIf
    
    If hConnect : InternetCloseHandle_(hConnect) : EndIf 
    If hInternet : InternetCloseHandle_(hInternet) : EndIf 
EndProcedure
;--------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------
sessionftp\server="ftp.jetstreamgames.co.nz"
sessionftp\username="anonymous"
sessionftp\password="1@2.3"
sessionftp\remotefile="/pub/ut/maps/ctf-2fortsinhell.zip"
sessionftp\localfile="ctf-2fortsinhell.zip"
sessionftp\port=21
sessionftp\proxyname=""
sessionftp\proxybypass=""
FTPGetFile()
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Have you read the MSDN doc about 'InternetSetStatusCallback'? It says that:
Returns the previously defined status callback function if successful, NULL if there was no previously defined status callback function, or INTERNET_INVALID_STATUS_CALLBACK if the callback function is not valid.
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

Have you read the MSDN doc about 'InternetSetStatusCallback'? It says that:
yes.. how do you think I wrote the function call :)

Code: Select all

 

; Since there is no previously defined status callback function, this one is the only one that exists.
; Thus the return from InternetSetStatusCallback() should not be #FALSE
; or NULL, but a pointer, to the existing InternetStatusCallback() defined by InternetSetStatusCallback_(hInternet,@InternetStatusCallback())
; 

Procedure InternetStatusCallback(hInternet.l,Context.l,InternetStatus.l,StatusInformation.l,StatusInformationLength.l) 
    Debug("!") 
EndProcedure 
I've written my own userlib for the function call, but I get the exact same result 0, so either I've done exactally what Fred has done, and we've both buggered up, or the PB Source is wrong.
Fred
Administrator
Administrator
Posts: 18353
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

As pupil said, 0 means: it works ! :). So what's exactly the problem ?
Post Reply