unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Memo1: TMemo;
Button1: TButton;
Memo2: TMemo;
Label1: TLabel;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
WINDIR, ETCDIR, HOSTSFILE:
String;
implementation
{$R *.dfm}
function ExpandEnvStr(
const szInput:
string):
string;
const
MAXSIZE = 32768;
begin
SetLength(Result,MAXSIZE);
SetLength(Result,ExpandEnvironmentStrings(pchar(szInput),
@Result[1],length(Result)));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// C:\WINNT\system32\drivers\etc\hosts
WINDIR := ExpandEnvStr('
%windir%');
// Funktion existier hier aus DP
ETCDIR := WINDIR + '
\system32\drivers\etc';
HOSTSFILE := ETCDIR + '
\hosts';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// Lesen der Hosts Datei
Memo1.Lines.Add('
Windir: ' + WINDIR);
Memo1.Lines.Add('
etcdir: ' + ETCDIR);
Memo1.Lines.Add('
hostsfile: ' + HOSTSFILE);
end;
end.