Solved

How can I get the value of specific environment variable?

Posted on 2001-08-23
3
231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

632 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