Solved

How can I get the value of specific environment variable?

Posted on 2001-08-23
3
225 Views
Last Modified: 2010-04-06
Hello,

I am new to Delphi. I have a question about the environment variable manipulation. I want to know how to define a global environment variable through the program, and how to retrieve the value from existing environment variable?

Many thanks,

ngpk





0
Comment
Question by:ngpk
  • 2
3 Comments
 

Expert Comment

by:d32coder
ID: 6420821
The TRegistry class gives you access to the system registry.

 var Reg: TRegistry; Str: String;

 Reg := TRegistry.Create;

  // set the Registry directory, I forget how
  // Reg.Open('/Variable Path/');
  // Note: HKEY CURRENTUSER is default
 if Reg.ValueExists('GlobalVar') then
  Str := Reg.ReadString('GlobalVar') else
    Str := '';
 ....
 Reg.WriteString('GlobalVar',Str);


 Reg.Free;



Hope this gets you in the right direction, you didn't say which var you are looking for.

Don
0
 
LVL 8

Accepted Solution

by:
TOndrej earned 10 total points
ID: 6420854
Have a look at GetEnvironmentStrings, GetEnvironmentVariable, SetEnvironmentVariable, FreeEnvironmentStrings APIs
0
 

Expert Comment

by:d32coder
ID: 6428685
Are those the variables such as ShortDateFormat?

Don
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now