Solved

how to get environment variables in delphi3

Posted on 1998-12-01
5
269 Views
Last Modified: 2010-04-04
How can I get the environment variables (e.g.: PATH or USERNAME) in a Delphi3-program ??? What is the function therfor?
0
Comment
Question by:pman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Accepted Solution

by:
mtieland earned 50 total points
ID: 1348746
The solution is as follows:

uses Windows

function TForm1.GetEnvVar(EnvName : EnvInp):string;
var EnvBuffP : array [0..255] of Char;
begin
   EnvBuffP:='';
   GetEnvironmentVariable(EnvName,EnvBuffP,30);
   GetEnvVar:=EnvBuffP;
end;

Good Luck

Martijn
0
 

Expert Comment

by:mtieland
ID: 1348747
Forgot to tell you:

how to use the function:
type SET in a dosbox to find out the names of the EnvVars

Lets say you want the username:

var UserName : String;

UserName:=GetEnvVar('USERNAME');

Good Luck
0
 
LVL 3

Expert Comment

by:williams2
ID: 1348748
..Wouldn't it be nice to now, which variables were available?

/Williams
0
 

Expert Comment

by:mtieland
ID: 1348749
That was not the question I think? Williams
0
 
LVL 3

Expert Comment

by:williams2
ID: 1348750
I know, that's why I asked pman. Maybe he didn't know it was possible :-)

Relax Martijn ..You answered his question, so you well enough deserve the credits!

/Williams
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question