For information about the environment, use the function GetEnvironmentVariable
, according to this page , you can use it from the following mode:
function GetEnvVarValue(const VarName: string): string;
var
BufSize: Integer;
begin
BufSize := GetEnvironmentVariable(PChar(VarName), nil, 0);
if BufSize > 0 then
begin
SetLength(Result, BufSize - 1);
GetEnvironmentVariable(PChar(VarName),
PChar(Result), BufSize);
end
else
Result := '';
end;
Example usage:
ShowMessage(GetEnvVarValue('windir')); // Exibe a localização do diretório do Windows
The values you can pass as arguments to the above function are:
-
ALLUSERSPROFILE
-
APPDATA
-
CLIENTNAME
-
CommonProgramFiles
-
COMPUTERNAME
-
ComSpec
-
HOMEDRIVE
-
HOMEPATH
-
LOGONSERVER
-
NUMBER_OF_PROCESSORS
-
OS
-
Path
-
PATHEXT
-
PCToolsDir
-
PROCESSOR_ARCHITECTURE
-
PROCESSOR_IDENTIFIER
-
PROCESSOR_LEVEL
-
PROCESSOR_REVISION
-
ProgramFiles
-
SESSIONNAME
-
SystemDrive
-
SystemRoot
-
TEMP
-
TMP
-
USERDOMAIN
-
USERNAME
-
USERPROFILE
-
windir
A list of variables and their default values can be seen in this Wikipedia page .