My Apologies, I got the help from our companies central help server, and
send the post before checking it myself.
When I looked further into the company's help files they didn't mention
where it was declared, but gave another function.
The way that they do it is in the following way/
function TGenFuncUtils.GetEnvironment(const EnvVar,default : string) :
string;
var
EnvList, Value, Name : PChar;
EnvName : string;
SignPos : integer;
found : boolean;
begin
EnvList := GetEnvironmentStrings;
found := false;
while EnvList^ <> #0 do
begin
EnvName := StrPas(EnvList);
SignPos := pos('=',EnvName);
EnvName := copy(Envname,1,SignPos-1); // truncate Envname to remove
value
if EnvName = EnvVar then
begin
Name := StrAlloc(255); //allocate memory for name variable
Value := StrAlloc(255); // allocate memory for value variable
StrPCopy(Name,EnvName); // copy string value 'EnvName' to PChar
Name
GetEnvironmentVariable(Name, Value, 255);
found := true;
Result := StrPas(Value); //convert value to string and assign to
Result
StrDispose(Name);
StrDispose(Value);
break;
end;
Inc(EnvList, StrLen(EnvList)+1);
end;
if not(found) then
begin
MessageDlg('Cannot Find Environment
Variable'+#10#13+#10#13+'Continuing with default
values',mtinformation,[mbOk],0);
Result := default;
end;
end;
ShowMessage(GetEnvironment('CommonProgramFiles', 'Default Value'));
Again my apologies
Johan Fourie
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Rob Kennedy
Sent: 10 May 2005 04:35
To: Borland's Delphi Discussion List
Subject: Re: How to fetch environment variables correctly
Johannes Fourie wrote:
> If I understand you correcttly then these Two API functions will serve
> you:
>
> <snip>
> SetEnvironment and GetEnvironment.
Where are those functions? They aren't documented at all in MSDN, and
they are not exported by Gdi32.dll.
--
Rob
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi
NOTICE: Please note that this eMail, and the contents thereof, is subject to
the standard arivia.kom email disclaimer which may be found at:
http://www.arivia.co.za/internet/disclaimer.htm. If you cannot access the
disclaimer through the URL attached, and you wish to receive a copy thereof,
please send an eMail to [EMAIL PROTECTED] or call (011) 233-0800. You will
receive the disclaimer by return email or fax.
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi