Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to get environment variables in delphi3

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

916 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