Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WSH: how to get dfault TEMP dir
Message
From
10/11/2001 05:02:59
 
 
To
09/11/2001 21:21:30
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00394247
Message ID:
00580099
Views:
33
>If all else failed, did you try GETENV() ?
>

The user Temp folder is the Windows Temp folder for all intents and purposes, although the content of the system process' TEMP environment variable may be different than the TEMP variable in the current user context. You can always fall back on the GetTempPath() API call:
DECLARE INTEGER GetTempPath IN Kernel32.DLL ;
   INTEGER nBufferLength, ;
   STRING @ lpBuffer
cBuffer = REPL(CHR(0), 1024)  && May be no larger than 261 if not XP/Win2K
nNumTCHAR = GetTempPath(1023,@cBuffer)
? 'Temporary Path is: ' + LEFT(cBuffer, nNumTCHAR)
If nNumTCHAR is 0, an error occurred and you need to call GetLastError() to get the error code. If nNumTCHAR > nBufferLength, this represents the length of the buffer required to hold the path, and the content of cBuffer is inconsistant.

You can also use the SHGetFolderPath(), SHGetSpecialFolderPath(), SHGetFolderLocation(), SHGetSpecialFolderLocation() and SHGetFolderPathAndSubDir() API calls to ret of a number of paths identified by CSIDLs, a special enumeration of common folder locations that is unfortunately Windows version specific as to exactly which CSIDLs are supported, and whether or not a given function is supported for a given Windows version revision. You'll need the MSDN Library (Platform SDK reference), and you'll need to retrieve the SHELL32.DLL version to know which calls are available. Sorry, but a comprehensive reference to these would take a lot more than a single message to cover adequately. There are a couple of these calls documented in the Win32 API section here on UT.

>>>I will get in before Ed here.
>>>
>>>oWSH=CreateObject("scripting.filesystemobject")
>>>oTempFolder=oWSH.GetSpecialFolder(2) && TempFolder
>>>?oTempFolder.Path
>>>
>>>
>>>>How can i get the windows default temp dirlike c:\windows\temp or c:\winnt\temp.
>>>>I looked in WSH (dino Esposito) but find only folders like Mydocuments but not temp.
>>>>Any help (Ed Rauh where are you)would be appriciated
>>>>
>>>>
>>>>Peter
>>
>>That gives you the current user temp dir but not the system temp dir (more important for me). Got any ideas?
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform