VB and VBA Users Source Code: Return the path of the windows directory
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Return the path of the windows directory
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Saturday, January 13, 2001
Hits:
547
Category:
Windows API
Article:
The following routine returns the path of the windows directory: Option Explicit Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long 'Purpose : Returns the path of the windows directory 'Inputs : N/A 'Outputs : The windows path name 'Author : Andrew Baker 'Date : 13/01/2001 21:00 'Notes : 'Revisions : Function DirWindows() As String Dim lLenTemp As Long Static ssWinDir As String If Len(ssWinDir) = 0 Then lLenTemp = 150 ssWinDir = String$(lLenTemp, vbNullChar) 'Get the username lLenTemp = GetWindowsDirectory(ssWinDir, lLenTemp) 'strip the rest of the buffer ssWinDir = Left$(ssWinDir, lLenTemp) If Right$(ssWinDir, 1) <> "\" Then ssWinDir = ssWinDir & "\" End If End If DirWindows= ssWinDir End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder