Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetTempPath Help Needed

Status
Not open for further replies.

dirksm

Programmer
Mar 14, 2002
22
0
0
GB
Hi All.

Can anybody help me with the GetTempPath API call?

I've got the

Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

declare in my form, but there seems to be some trickery involved in actually getting the path, since the function returns the length rather than the value of the path. I am under the impression that the buffer string should contain the path, but that doesn't seem to be correct.

Maybe there is a different/easier way of getting the user's temp path or maybe you can show me how this API call works.

Please help!!
 
You must first initialize the buffer something like the following:

strTemp = String(100, Chr$(0)) ' specify the length

Then call the API

GetTempPath 100, strTemp ' Use same len and variable

The strip the buffer

strTemp = Left(strTemp, InStr(strTemp, Chr$(0)) - 1)

strTemp should now have your path.

Hope this helps Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Add a reference To Microsoft Scripting Runtime.

Create an isnstance of the FileSystemObject (might not be exactly called that)

Call .GetSpecialFolder(<SpecialFolderConst>)

<SPecialFolderConst> = TemporaryFolder
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top