For information about the environment, use the function GetEnvironmentVariable
, according to that page, you can use it as follows:
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 of use:
ShowMessage(GetEnvVarValue('windir')); // Exibe a localização do diretório do Windows
The values you can pass as argument 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.
Variables of windows environment?
– rray