Thread View: borland.public.delphi.language.delphi.general
2 messages
2 total messages
Started by cantak
Fri, 16 Apr 2010 20:18
How to get the full path (not the executable)
Author: cantak
Date: Fri, 16 Apr 2010 20:18
Date: Fri, 16 Apr 2010 20:18
8 lines
1775 bytes
1775 bytes
Go to a DOS prompt. Type 'Whatever' in and press Enter. As long as 'Whatever' exists in a set of various system paths it will be executed. Now, in a Delphi application I want to get the full path to 'Whatever'. So, I need to do the following as far as I can tell: - Check the current path - Application.ExeName - Loop the command line paths one at a time and look for the file. How do I get that information?
Re: How to get the full path (not the executable)
Author: cantak
Date: Mon, 19 Apr 2010 17:58
Date: Mon, 19 Apr 2010 17:58
12 lines
1858 bytes
1858 bytes
Nevermind, found it. For anyone else searching, the code is below:
BuffSize : integer;
s : string;
BuffSize := GetEnvironmentVariable(PChar('PATH'), nil, 0); // Get
required buffer size including the null terminator
if BuffSize > 0 then begin
// Read env var value into result string
SetLength(s, BuffSize - 1); // skipping the terminator
GetEnvironmentVariable(PChar('PATH'), PChar(s), BuffSize);
end;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads