--- In advanced_delphi@yahoogroups.com, "Glenn Lawler" <gblaw...@...> wrote: > > I have translated the prototype for DoFileDownload from VB to Delphi as > follows: > > VB: > Private Declare Function DoFileDownload Lib "shdocvw" (ByVal lpszFile As > String) > As Long > > Delphi: > function DoFileDownload(lpszFile: PChar): Longint; far; external > 'shdocvw.dll'; > > When I call it, I get a warning dialog "Download could not complete" with a > series of unprintable characters followed by the word "from". > The program is then apparently closed by Windows. > > As I understand this call, lpszFile is the URL to download. > > Thought it might be a widestring, so redefined as: > function DoFileDownload(lpszFile: PWideChar): Longint; far; external > 'shdocvw.dll'; > > No joy. > > Anyone have a very simple working example that makes this call? > > Thanks, > > Glenn Lawler > www.incodesystems.com >
Hi Glenn, I don't know if you're aware that... DoFileDownload is dependent on the security settings of the users Internet Explorer. So it "may" or "may not" cause problems. Another API function that might be better is... Declare Function URLDownloadToFile _ Lib "urlmon" Alias "URLDownloadToFileA" _ (ByVal pCaller As Long, ByVal szURL As String, _ ByVal szFileName As String, ByVal dwReserved As Long, _ ByVal lpfnCB As Long) As Long In another programming language that I use, I've had success calling it by using... Dim sUrl As String sUrl = "www.yahoo.com" Dim sLocalFile As String sLocalFile = "c:\temp\yahoo_index.html" Dim lRet As Long lRet = URLDownloadToFile(0, sURL, sLocalFile, 0, 0) If lRet = 0 (zero) the download was successful. The downloaded file will be in the folder that you specified. David