unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm2 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
memo1.Lines.SaveToFile('C:\Windows\System32\drivers\etc\hosts');
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
memo1.Clear;
if FileExists('C:\Windows\System32\drivers\etc\hosts') then begin
memo1.Lines.LoadFromFile('C:\Windows\System32\drivers\etc\hosts');
end Else begin
memo1.Lines.Add('C:\Windows\System32\drivers\etc\hosts,不存在!!!')
end;
end;
end.
delphi编辑hosts文件
最新推荐文章于 2019-02-27 14:10:39 发布