Solved

Full Path of Windows Temp folder

Posted on 2011-03-08
8
1,295 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 23

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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

22 Experts available now in Live!

Get 1:1 Help Now