Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Full Path of Windows Temp folder

Posted on 2011-03-08
8
Medium Priority
?
1,325 Views
Last Modified: 2012-05-11
How to get windows temp folder without truncation of folder name?
All solutions give C:\Docume~1\....
whereas I want it as C:\Documents and Settings\...

Removed the "TCP / IP" Zone, as it has nothing to do with the Q.

rindi,
EE ZA Storage

Open in new window

0
Comment
Question by:Allan_Fernandes
[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
8 Comments
 
LVL 29

Expert Comment

by:Dr. Klahn
ID: 35068520
This can be found in the registry key:

HKEY_CURRENT_USER/Environment/TEMP

It is of type REG_EXPAND_SZ.
0
 
LVL 8

Expert Comment

by:MarkieS
ID: 35068540
Or %TEMP% is usually environment variable..
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 35068835
%TEMP% and %TMP% both give windows short names and NOT the full path as requested.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 37

Expert Comment

by:Neil Russell
ID: 35068855
Here is an example of how to do it via VB6. you should be able to adapt the info on using the Kernel32 API's
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 35068859
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 35068878
It will NORMALLY be %USERPROFILE%\Local Settings\Temp

you can do that in a cmd prompt to expand

c:\> ECHO %USERPROFILE%\Local Settings\Temp
0
 

Accepted Solution

by:
Allan_Fernandes earned 0 total points
ID: 35079314
Somehow GetLongPathName (delphi 5 and 2007) is not giving results, did not dig-in.
Managed to get a simple code that delivers across all versions.


Function LongFileName(ShortName: String): String;
// Usage: LongFileName('c:\DOCUME~1\User\LOCALS~1\Temp')
// Parameter=ShortName : Can be a filename or Foldername
// Returns '' if invalid input.
var
  SR: TSearchRec;
Begin
  Result := '';
  if not (DirectoryExists(ShortName) or FileExists(ShortName)) then
     exit ;
  If (pos('*',ShortName)+pos('?',ShortName) <> 0) Then
  Begin    { ignore joker chars }
    Exit;
  End;
  While FindFirst(ShortName, faAnyFile, SR) = 0 Do
  Begin
    { next part as prefix }
    Result := '\' + SR.Name + Result;
    SysUtils.FindClose(SR);  { the SysUtils, not the WinProcs procedure! }
    { directory up (cut before '\') }
    ShortName := ExtractFileDir (ShortName);
    If length (ShortName) <= 2 Then
    Begin
      Break;  { ShortName contains drive letter followed by ':' }
    End;
  End;
  Result := ExtractFileDrive (ShortName) + Result;
end;

Original code: http://www.delphi3000.com/articles/article_1304.asp?SK=
0
 

Author Closing Comment

by:Allan_Fernandes
ID: 35120749
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you build your web application in Visual Studio you'll get at least a few binaries, or .DLL, files in your bin folder. However, there is more compiling to be done. Normally this would happen when an ASP.NET resource within the web site is request…
Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

636 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