Solved

Getting Windows Temp Directory

Posted on 1998-09-14
4
171 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
4 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 50 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now