Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs,URLMon, ShellApi, StdCtrls, Vcl.Menus;
- type
- TForm1 = class(TForm)
- MainMenu1: TMainMenu;
- PROGRAMASABAIXO1: TMenuItem;
- CLICARAQUIPARANODEIXAROCORELBLOQUEAR1: TMenuItem;
- procedure CLICARAQUIPARANODEIXAROCORELBLOQUEAR1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- function DownloadFile(SourceFile, DestFile: string): Boolean;
- begin
- try
- Result := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0;
- except
- Result := False;
- end;
- end;
- procedure TForm1.CLICARAQUIPARANODEIXAROCORELBLOQUEAR1Click(Sender: TObject);
- const
- SourceFile = 'http://www.mysite.com/image.gif';
- DestFile = 'c:\image.gif';
- begin
- if DownloadFile(SourceFile, DestFile) then
- begin
- ShowMessage('Download succesful!');
- ShellExecute(Application.Handle, PChar('open'), PChar(DestFile),
- PChar(''), nil, SW_NORMAL)
- end
- else
- ShowMessage('Error while downloading ' + SourceFile)
- end;
- end.
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement