-
I use this API to download files:
Code:
Public Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, _
ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
The problem is I want to use a progress bar and I have no idea how to make that :( Any help appreciated!
-
-
Fox, I did ask for this before and yet no reply so far :(
-
I emailed a anti-virus program company called Protector Plus and asked them how to do it, because they use the urlmon.dll and it shows the progress, how much is complete, how much time is remaining, etc.
They emailed back, and didn't seem to know how to do it :rolleyes:.
To me, they were playing dumb, but they probably just didn't want to tell me :(.
-
so I'll try to figure it out..
I'll post here when done :D
-
it's done using a callback interface (Says MSDN). I don't think it's possible in VB, becuase i don't think you can create a Callback Interface. Maybe it's possible, but i don't think so
-
If it's impossible that would explain why I didnt' know how to do it in VB (since I know how to do it in C) but I think there must be a way ;)
-
fox, how are you using the call?
i.e. what are you using as parameter 1?
-
Try using hooks and seeing if you can get any extra info that way (eg. bytes done) and if you know how many bytes there are at the start then you are on your way!
-
its not that simple sastraxi - look up the function in MSDN:
HRESULT URLDownloadToFile(
LPUNKNOWN pCaller,
LPCSTR szURL,
LPCSTR szFileName,
DWORD dwReserved,
LPBINDSTATUSCALLBACK lpfnCB
);
the last param is apparently:
Address of the caller's IBindStatusCallback interface. URLDownloadToFile calls this interface's IBindStatusCallback::OnProgress method on a connection activity, including the arrival of data. IBindStatusCallback::OnDataAvailable is never called. Implementing IBindStatusCallback::OnProgress allows a caller to implement a user interface or other progress monitoring functionality. It also allows the download operation to be canceled by returning E_ABORT from the IBindStatusCallback::OnProgress call. Can be NULL
So..i'd guess you'd need a class that implements this interface; thats in MSDN too. then you'd pass a pointer to an instance of that class?
Dim BindStatCB as new IBindStatusCallback
i.e. ObjPtr(BindStatCB)
If you can find a TLB/DLL that has IBindStatusCallback in it, then you don't have to write the class yourself.
NOTE: this probably won't work :)
-
I think Fox you are already doing this, but can't you make a Dll/ocx in C/C++ which monitors the download (and which has a visible component ) and use it in your application. If you are doing this or are planning to do this, could you send me the dll/ocx also(I am not hat comfortabl with C)
-