in reply to Re: Win32::API help
in thread Win32::API help
That won't work. The result is a trap (protection violation), because Win32::API doesn't know how to translate undef into a C-type null. This is 5.8.8, but you get the same result from 5.8.6:
C:\test>\AS817\perl\bin\perl5.8.8.exe -Mlib=\perl\site\lib -MWin32::A +PI -mstrict -w Win32::API->Import( 'urlmon', 'URLDownloadToFile', 'PPPNP', 'N', ); my $pCaller = 0; my $szURL = 'http://somedomain.com/pic.jpg'; my $szFileName = 'c:\1img.jpg'; my $dwReserved = 8; # Download from offline cache my $lpfnCB = 0; my $res = URLDownloadToFile( undef, $szURL, $szFileName, $dwReserved, undef, ) or die Win32::FormatMessage(Win32::GetLastError); ^Z Use of uninitialized value in subroutine entry at (eval 2) line 2, <DA +TA> line 164. Use of uninitialized value in subroutine entry at (eval 2) line 2, <DA +TA> line 164.
This way doesn't result in a trap, though I've failed to make it download any file. Possibly because 0x8 means fetch it from the cache, but as I don't use IE, it won't find it there.
C:\test>perl -Mlib=\perl\site\lib -MWin32::API -mstrict -w Win32::API->Import( 'urlmon', 'URLDownloadToFile', 'PPPNP', 'N', ); printf "%08x\n", URLDownloadToFile( 0, 'http://images.google.com/intl/en/images/images_res.gif', 'google.gif', 8, 0, ) or die $^E; ^Z 800c0005
The return code 0x800c005 apparently means file or server not found.
The following codes are other common error codes: - 80100003. During install, one or more files are missing from downlo +ad folder. - 800bxxxx. Anything starting with 800b is a trust failure (for examp +le, 800b010b - trust check failed). - 800Cxxxx. Anything starting with 800C is a Urlmon failure (for exam +ple, 800C0005 - file or server not found, 800C000B - connection timeout). - 80040004. User canceled.
Which doesn't make a great deal of sense as my browser can fetch the gif above, but at least the call has successfully been made without trapping.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Win32::API help
by ikegami (Patriarch) on Nov 07, 2006 at 02:08 UTC |