in reply to Win32::API help
That pack is definitely wrong. $dwReserved should be simply 8.
The signature is completely wrong
HRESULT -> N or I, not sure URLDownloadToFile( LPUNKNOWN pCaller, -> P LPCTSTR szURL, -> P LPCTSTR szFileName, -> P DWORD dwReserved, -> N LPBINDSTATUSCALLBACK lpfnCB -> P );
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( $pCaller, $szURL, $szFileName, $dwReserved, $lpfnCB, ) or die Win32::FormatMessage(Win32::GetLastError);
If that doesn't work, also make sure the DLL function was compiled using the __stdcall (aka WINAPI) calling convention. Win32::API can't call it properly if it wasn't.
HRESULT WINAPI URLDownloadToFile( LPUNKNOWN pCaller, LPCTSTR szURL, LPCTSTR szFileName, DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB );
Update: Replaced undef with $pCaller and $lpfnCB.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Win32::API help
by BrowserUk (Patriarch) on Nov 07, 2006 at 02:06 UTC | |
by ikegami (Patriarch) on Nov 07, 2006 at 02:08 UTC | |
|
Re^2: Win32::API help
by pKai (Priest) on Nov 07, 2006 at 11:53 UTC |