Solved

Getting Windows temp directory

Posted on 2000-05-13
2
331 Views
Last Modified: 2012-05-04
Is there a way to return the local computer's Windows temp directory besides GetTempPathA (which has been given me the most illogical errors in my code)?  It works and returns the right path, but absolutely makes my code go nuts.
0
Comment
Question by:uhoang
  • 2
2 Comments
 
LVL 15

Accepted Solution

by:
simonet earned 50 total points
ID: 2807860
Here it is:

function GetTempPathStr : string;
var
  pTempPath : pchar;
begin
  pTempPath := StrAlloc(MAX_PATH + 1);
  GetTempPath(MAX_PATH+1, pTempPath);
  Result := string(pTempPath)
  StrDispose(pTempPath);
end;


Now just use the function GetTempPathStr whenever you need the Temp path.

Yours,

Alex
   
0
 
LVL 15

Expert Comment

by:simonet
ID: 2814966
Why a B if the routine works fine?

Alex
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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