开发者

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.


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;


Without header file we can not know what is LPBINDSTATUSCALLBACK for example. The best approach is to google around if someone has already made a conversion of the whole header file. If there isn't one, then try some C to Delphi convertor (http://www.drbob42.com/delphi/headconv.htm, http://cc.embarcadero.com/item/26951). Beware that they can only convert 60-80% of the code, but hopefully part you are interested in will be converted. If you are still stuck after all this, then search for VB conversion of the header. It will be much easier then conversion from C.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜