Solved

How can I get the value of specific environment variable?

Posted on 2001-08-23
3
224 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
Comment Utility
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
Comment Utility
Have a look at GetEnvironmentStrings, GetEnvironmentVariable, SetEnvironmentVariable, FreeEnvironmentStrings APIs
0
 

Expert Comment

by:d32coder
Comment Utility
Are those the variables such as ShortDateFormat?

Don
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

11 Experts available now in Live!

Get 1:1 Help Now