Solved

Full Path of Windows Temp folder

Posted on 2011-03-08
8
1,302 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
8 Comments
 
LVL 25

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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

It is only natural that we all want our PCs to be in good working order, improved system performance, so that is exactly how programs are advertised to entice. They say things like:            •      PC crashes? Get registry cleaner to repair it!    …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

813 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

11 Experts available now in Live!

Get 1:1 Help Now