Registriert seit: 29. Mai 2002
37.621 Beiträge
Delphi 2006 Professional
|
Re: variablen von cmd
14. Mai 2006, 17:57
Delphi-Quellcode:
(*
* Author : Michael Puff - [url]http://www.michael-puff.de[/url]
* Date : 2006-05-14
* License : PUBLIC DOMAIN
*)
function ReadEnviromentVariable( const Variable: string; var Value: string): DWORD;
var
error : DWORD;
Buffer : PChar;
len : Integer;
begin
error := 0;
len := GetEnvironmentVariable(PChar(Variable), nil, 0);
if len > 0 then
begin
try
Buffer := GetMemory(len);
len := GetEnvironmentVariable(PChar(Variable), Buffer, len);
SetString(Value, Buffer, len);
finally
FreeMemory(Buffer);
end;
end
else
error := GetLastError;
result := error;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
s : string;
error : Integer;
begin
error := ReadEnviromentVariable(' windir', s);
if error <> 0 then
s := SysErrorMessage(error);
ShowMessage(s);
end;
Michael Ein Teil meines Codes würde euch verunsichern.
|
|
Zitat
|