Jump to content

DllCall DoFileDownload (shdocvw.dll)


therks
 Share

Recommended Posts

*Edit: Okay, so I figured out the first error I was getting, but I still get the second one. Anybody have any ideas?

Any idea how I could get this to work? From what I've read, it's supposed to give me the default IE file download dialog (allow me to choose a place to save the file, then the usual download window with progress bar etc). But all I get is a couple errors.

$sFile = 'http://www.therks.com/public/toby/toby.jpg'

DllCall('shdocvw.dll', 'int', 'DoFileDownload', 'str', $sFile)

First error:

AutoIt v3: AutoIt3.exe - Entry Point Not Found (window title)

The procedure entry point GetProcessImageFileNameW could not be located in the dynamic link library PSAPI.DLL

Second error:

Security Alert (window title)

Your current security settings do not allow this file to be downloaded.

Any help would be appreciated. I just wanted a simple call to the default dialog, don't want to recreate my own.

Thanks!

Edited by Saunders
Link to comment
Share on other sites

First error:

AutoIt v3: AutoIt3.exe - Entry Point Not Found (window title)

The procedure entry point GetProcessImageFileNameW could not be located in the dynamic link library PSAPI.DLL

PSAPI.DLL??? Where do you call that DLL? Is there more code?

Second error:

Security Alert (window title)

Your current security settings do not allow this file to be downloaded.

AFIAK the string has to be in UNICODE format!

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

  • 2 months later...

"Rise from your grave" </Altered Beast>

Sorry to revive a dead thread, but now that AutoIt supports unicode format, it's plausible that this function should be workable, right?

I figured out the first error. It looks like the psapi.dll that ships with AutoIt doesn't have that function within it, so I just deleted that one, and now it's using the one in my system32 folder. The only error I get now is the security settings one.

Link to comment
Share on other sites

  • 2 weeks later...
  • 9 months later...
  • Moderators

I thought this would work... but I keep getting the same error:

$sDURL = 'http://www.therks.com/public/toby/toby.jpg'
_DoFileDownload($sDURL)

Func _DoFileDownload($sURL)
    Local $hModOLE = DllOpen("ole32.dll")
    If @error Then Return SetError(1, @error, 0)
    
    DllCall($hModOLE, "int", "CoInitialize", "uint", 0)
    If @error Then Return SetError(2, @error, 0)
    
    Local $hModSHD = DllOpen("shdocvw.dll")
    If @error Then Return SetError(3, @error, 0)
    
    Local $nBuffSize = StringLen($sURL) * 2
    Local $tStruct = DllStructCreate("byte[" & $nBuffSize + 2 & "]")
    Local $tBuffer = DllStructCreate("byte[" & $nBuffSize & "]", DllStructGetPtr($tStruct) + 2)
    Local $aMBWC = DllCall("kernel32.dll", "int", "MultiByteToWideChar", _
        "int", 0,"int", 0, "str", $sURL, "int", StringLen($sURL), _
        "ptr", DllStructGetPtr($tBuffer, 1), "int", $nBuffSize)
    If @error Then Return SetError(4, DllClose($hModSHD) + DllClose($hModOLE), 0)

    Local $aDFD = DllCall($hModSHD, "int", "DoFileDownload", "wstr", DllStructGetData($tBuffer, 1))
    If @error Then Return SetError(5, DllClose($hModSHD) + DllClose($hModOLE), 0)
    Return DllClose($hModSHD) + DllClose($hModOLE)
EndFunc

I don't know really, maybe something to chew on a bit.

Edit:

Had str for one of the params for DllCall to shd, should have been wstr.

Anyway, I also tried DoFileDownloadEx and that doesn't work either... Even with security settings on low (Win XP Pro SP2)... But it did work on Win 2k.

Edited by SmOke_N

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

I think this may let you do it, but it requires you to reset Internet Explorer's security settings. Ultimately, this simply scares me because on my high level custom IE security settings, I still feel like I am dropping trow every time I use IE to go on the internet. Luckily for me, I only use IE for checking my M$ email accounts. I use Firefox exclusively for everything else.

Article regarding making changes in security to get rid of the problem:

http://support.microsoft.com/kb/899630

I think the best solution would simply be to write your own script with a GUI for download progress. I have one that I wrote that mimics that of an IE download. Let me know if you are interested Saunders.

- The Kandie Man ;-)

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

  • Moderators

I think the best solution would simply be to write your own script with a GUI for download progress. I have one that I wrote that mimics that of an IE download. Let me know if you are interested Saunders.

He did indeed write a nice one...

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

Colour me interested. I've started to make one myself several times but always gave up because I couldn't get some aspect of the implementation to work. I think the big thing for me was the fact that IE always seemed to be able to harvest the proper filename, even when the URL didn't contain it. (ie: http://site.com/script.php?download=14814 becomes myprogram.exe)

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...