Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read the "PATH"? 1

Status
Not open for further replies.

eladna

Programmer
Dec 11, 2002
17
0
0
IL
Hi
I have an external program which I run with a batch file from my program.
While the installation of the external program it has been added to the "PATH"

I would like to know how I could I read the PATH so I could tell if the program has been installed or not and give a warning if needed.

Thanks.
 
The path is an environment variable. You can see them listed from a command prompt by typing set.

To access any of these variables, use the Delphi function:
[tt]GetEnvironmentVariable(sVarname)[/tt]
where sVarname is the environment variable - in your case 'PATH'.
The function returns a string, so you need to search the returned string for your pathname. So to search for [tt]c:\MyPath[/tt] and get a warning about its non-existance:
Code:
  if pos('C:\MyPath',GetEnvironmentVariable('PATH')) = 0 then
    MessageDlg('Application not installed',mtWarning,[mbOk],0);

Hope that helps

Cheers,
Chris [pc2]
 
This exactly what I wanted and even more
Thank you very much, it works great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top