Advertisement
hosttimer

programa pra baixa algo da internet

Sep 28th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.24 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs,URLMon, ShellApi, StdCtrls, Vcl.Menus;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     MainMenu1: TMainMenu;
  12.     PROGRAMASABAIXO1: TMenuItem;
  13.     CLICARAQUIPARANODEIXAROCORELBLOQUEAR1: TMenuItem;
  14.     procedure CLICARAQUIPARANODEIXAROCORELBLOQUEAR1Click(Sender: TObject);
  15.   private
  16.     { Private declarations }
  17.   public
  18.     { Public declarations }
  19.   end;
  20.  
  21. var
  22.   Form1: TForm1;
  23.  
  24. implementation
  25.  
  26. {$R *.dfm}
  27.  function DownloadFile(SourceFile, DestFile: string): Boolean;
  28. begin
  29.   try
  30.     Result := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0;
  31.   except
  32.     Result := False;
  33.   end;
  34. end;
  35. procedure TForm1.CLICARAQUIPARANODEIXAROCORELBLOQUEAR1Click(Sender: TObject);
  36.  
  37.  const
  38.   SourceFile = 'http://www.mysite.com/image.gif';
  39.   DestFile = 'c:\image.gif';
  40. begin
  41.   if DownloadFile(SourceFile, DestFile) then
  42.   begin
  43.     ShowMessage('Download succesful!');
  44.     ShellExecute(Application.Handle, PChar('open'), PChar(DestFile),
  45.       PChar(''), nil, SW_NORMAL)
  46.   end
  47.   else
  48.     ShowMessage('Error while downloading ' + SourceFile)
  49. end;
  50.  
  51. end.
  52. end;
  53.  
  54. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement