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.
In reply to Re: Win32::API help
by ikegami
in thread Win32::API help
by Zukoff
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |