[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Getting Windows Temp Directory

Posted on 1998-09-14
4
Medium Priority
?
187 Views
Last Modified: 2010-04-06
I think I am overlooking something basic, but is there a easy way to get the current windows "temp" directory? This will need to work on W95, W98 and WinNT.
0
Comment
Question by:TonyMalo
[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
4 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 150 total points
ID: 1339710
Here is the easiest way....

var
  Temp : array[0..100]of char;
begin
  GetTempPath(SizeOf(Temp), Temp);
  ShowMessage(StrPas(Temp));
end;

Regards,
Viktor Ivanov
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1339711
Note:
Viktor, Tony, always set the upper boundary to MAX_PATH (144) when dealing with windows system paths.

var
  Temp: array[0..MAX_PATH] of Char;

/// John
0
 

Author Comment

by:TonyMalo
ID: 1339712
Tanks to all, I knew there was a simple answer
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1339713
One thing to watch:

result is:
1.The path specified by the TMP environment variable.
2.The path specified by the TEMP environment variable, if TMP is not defined.
3.The current directory, if both TMP and TEMP are not defined.

i've put some functions like the one you were looking for into a unit. this is what it looks like:

function strGet_SysDir: string;
begin
  p := StrAlloc(Succ(MAX_PATH));
  GetSystemDirectory(p, MAX_PATH);
  Result := StrPas(p);
  StrDispose(p);
end;

Black Death.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

650 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