Solved

How can I get the value of specific environment variable?

Posted on 2001-08-23
3
226 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

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…
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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

822 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