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