danke für die schnelle antwort: ich poste das nochnmal !
Delphi-Quellcode:
function GetEnvVarValue(const VarName: string): string;
var
BufSize: Integer; // buffer size required for value
begin
// Get required buffer size (inc. terminal #0)
BufSize := GetEnvironmentVariable(PChar(VarName), nil, 0);
if BufSize > 0 then
begin
// Read env var value into result string
SetLength(Result, BufSize - 1);
GetEnvironmentVariable(PChar(VarName),
PChar(Result), BufSize);
end
else
// No such environment variable
Result := '';
end;
procedure TForm1.Button1(Sender: TObject);
begin
ShowMessage(GetEnvVarValue('APPDATA'));
end;