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

x
?
Solved

How can I get the value of specific environment variable?

Posted on 2001-08-23
3
Medium Priority
?
234 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 40 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

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