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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Temp Directory 1

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello,

In VB5 I need to be able to determine the current users temp directory (full path) in Win9x\2k\XP.

What is the best way to get this?

Thanks,

Michael42
 
have a look at the gettemppath API call

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

i believe it works on all windows OS's (but not 100% certain)

good luck!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
come on... get involved!
To get the best response to a question, please check out FAQ222-2244 first
A General Guide To Excel in VB FAQ222-3383
 
ADoozer,

This looks like it might do the trick. Could you please give me an example of using this - setting a value to a variable.

I am not quite an API expert yet.



Thanks,

Michael42
 
Public Const MAX_PATH = 260

Public Function GetTempDirectoryPath() As String

Dim S As String

S = String(MAX_PATH + 1, 0)

lng = GetTempPath(MAX_PATH, S)

GetTempDirectoryPath = Left$(S, lng)

End Function

good luck

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
come on... get involved!
To get the best response to a question, please check out FAQ222-2244 first
A General Guide To Excel in VB FAQ222-3383
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top