Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to get environment variables in delphi3

Posted on 1998-12-01
5
Medium Priority
?
281 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 100 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

721 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