Jump to content

Help with API function URLDownloadToFile


Recommended Posts

I am trying to call a function called URLDownloadToFile(), in urlmon.dll.

Here is the function:

HRESULT URLDownloadToFile(    
    LPUNKNOWN pCaller,
    LPCTSTR szURL,
    LPCTSTR szFileName,
    DWORD dwReserved,
    LPBINDSTATUSCALLBACK lpfnCB
);
MSDN's reference for it can be found here: http://msdn.microsoft.com/en-us/library/ms775123.aspx.

My CallFunc() is returning @error = 2, which is "invalid return type". I am using str return type for the LPCTSTR's, and dword for DWORD. I'm not sure what to use for the others, and have been trying different things, but I keep getting the error. Anyone have experience calling API functions that can help me out? Here's my attempt to call it:

$test = DllCall(@SystemDir & "\urlmon.dll", "ulong", "URLDownloadToFile", "none", "", "str", $url, "str", "C:\TSE\TEST111.xml", "dword", 0, "int", 0)
Link to comment
Share on other sites

  • Moderators

Something wrong with InetGet()?

I think I ran into a problem once with this myself, but for the life of me can't remember what the solution was I found if any.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

ini parameters, you mustn't use "none", just use "ptr" instead :P

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

DllCall("urlmon.dll", "ptr", "URLDownloadToFile", "ptr", "0", "str", $url, "str", $filename, "dword", 0, "ptr", 0)

1. Pointers aren't necessarily identical in size to longs. If you're not sure of the exact pointer type, use "ptr" instead.

2. dwReserved should be 0... not sure why you'd send it 16.

Edited by -Ultima-

[ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...