Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi Download Video from the Internet using URLDownloadToFile

How can I implement the following Windows function in Delphi?

HRESULT URLDownloadToFile(      
  LPUNKNOWN pCaller,
  LPCTSTR szURL,
  LPCTSTR szFileName,
  DWORD dwReserved,
  LPBINDSTATUSCALLBACK lpfnCB
);  

URLDownloadToFile Function: http://msdn.microsoft.com/en-us/library/ms775123(VS.85).aspx

The question that prompted me was asked here.

Downloading flv from youtube using curlpp on top of curl - video not playing

Regards, Pieter.

like image 727
Pieter van Wyk Avatar asked Nov 01 '10 08:11

Pieter van Wyk


1 Answers

uses
  URLMon, ShellApi;

function DownloadFile(SourceFile, DestFile: string): Boolean;
begin
  try
    Result := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0;
  except
    Result := False;
  end;
end;
like image 110
G-Man Avatar answered Sep 28 '22 06:09

G-Man