Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: %PATH% Contents



Permlink Replies: 2 - Last Post: Nov 18, 2016 4:41 PM Last Post By: Remy Lebeau (Te...
Robert Penoyer

Posts: 15
Registered: 2/14/06
%PATH% Contents
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 17, 2016 8:22 PM
How can I access the contents of the System Path, %PATH% ?
Antonio Estevez

Posts: 665
Registered: 4/12/00
Re: %PATH% Contents
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 18, 2016 12:46 AM   in response to: Robert Penoyer in response to: Robert Penoyer
El 18/11/2016 a las 5:22, Robert Penoyer escribió:
How can I access the contents of the System Path, %PATH% ?

Call the Windows API function GetEnvironmentVariable:

    TCHAR SystemPath[4096];
 
    GetEnvironmentVariable(_T("PATH"), SystemPath, sizeof(SystemPath)/sizeof(TCHAR));


or the RTL wrap:

    String SystemPath= GetEnvironmentVariable(_D("PATH"));
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: %PATH% Contents [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 18, 2016 4:41 PM   in response to: Antonio Estevez in response to: Antonio Estevez
Antonio wrote:

or the RTL wrap:

String SystemPath= GetEnvironmentVariable(_D("PATH"));

The RTL wrapper is in System.SysUtils.hpp.

Note that the %PATH% value may (and likely will) contain other environment
variables. GetEnvironmentVariable() will not expand those to their respective
values. If you need to expand them, you will have to use the Win32 API ExpandEnvironmentStrings()
or ExpandEnvironmentStringsForUser() function.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02