This article was previously published under Q210158
Advanced: Requires expert coding, interoperability, and multiuser skills.
Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.
View products that this article applies to.
Option Compare Database
Option Explicit
Declare Function apiGetWindowsDirectory& Lib "kernel32" Alias _
"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long)
Declare Function apiGetSystemDirectory Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize _
As Long) As Long
' This function returns the path to the Windows directory
' as a string.
Function GetWinDir () As String
Dim lpbuffer As String * 255
Dim Length as Long
Length = apiGetWindowsDirectory(lpbuffer, Len(lpbuffer))
GetWinDir = Left(lpbuffer, Length)
End Function
' This function returns the path to the Windows System folder
' as a string.
Function GetSysDir () As String
Dim lpbuffer As String * 255
Dim Length as Long
Length = apiGetSystemDirectory(lpbuffer, Len(lpbuffer))
GetSysDir = Left(lpbuffer, Length)
End Function
? GetWinDir()
? GetSysDir()
Keywords: KB210158, kbprogramming, kbhowto