GetEnvironmentString函数可以代替
function GetDOSEnvVar ( const VarName: string ): string;
var
len: integer;
pDosEnv: PChar;
begin
result :='';
len := length ( varName );
PDosEnv := GetEnvironmentStrings;
if ( StrLIComp ( PDosEnv, @VarName [ 1 ], len ) = 0) and ( PDosEnv
len ] = ' ' ) then begin
result := strPas ( PDosEnv + len + 1 );
break;
end;
inc ( PDosEnv, strLen ( PDosEnv ) + 1 );
procedure GetEnvironmentList ( const List : TStrings );
{
获取环境变量列表
}
var
Buf , p : PChar ;
begin
Buf := GetEnvironmentStrings ;
p := Buf ;
while p ^ <> #0 do
begin
List . Add ( p );
Inc ( p , StrLen ( p ) + 1 );
end ;
FreeEnvironmentStrings ( Buf );
end ;