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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unix

Status
Not open for further replies.

cyberant

Programmer
Sep 21, 2003
44
ZA
How do I make a direct call to the operating system directory without necessarily having to say "c:\windows", is there not a command like $%OSRoot%$?

I'm pretty sure there are a number of such commands such as making a direct call to the root without having to type "c:\", is there perhaps a list where I could find such statements?
 
A function like this will do the job:
Code:
function GetWindowsPath: String;
begin
 SetLength(Result, MAX_PATH);
 GetWindowsDirectory(PChar(Result), MAX_PATH);
end;

Andrew
 
I'm storing a number of files within the windows temporary folder during the operation of my program (an email browser). I simply want to empty the temporary folder when I exit the program.
 
You'd better get a path to the windows Temp dir, and create a subdir, just for yourself, that you empty & delete on exit. This way you won't get conflicts with other programs that have open files in the temp dir.

Windows temp is not nessecerily in %WINDOWS%\TEMP, so ...

HTH
TonHu
 
And the way to get the Temp directory is to use something like this:
Code:
function GetTemporaryPath: String;
begin
 SetLength(Result, MAX_PATH);
 GetTempPath(MAX_PATH, pchar(result) );
end;
Note the annoying inconsistency in the order of parameters between GetTempPath and GetWindowsDirectory.

Andrew

 
I'm having trouble with getting the directory. When I check the contents of the result of the Function, the first part does display the directory but then i get a long line of gibberish i.e. ##@#@#$$ etc. I'm guessing that these characters must be place holders for the remaning characters as the path has not used the 255 character size specified by MAX_PATH.

Any ideas?

 
You prob. have to scan for the first #0 in the output to find the actual length of the path.

HTH
TonHu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top