|
|
Title | Find the Windows directory and system drive |
Keywords | windows directory, system drive |
Categories | Files and Directories, Tips and Tricks, Windows, API |
|
|
Use the GetWindowsDirectory API function to get the Windows directory. The leftmost character will give you the drive letter.
|
|
' Return the Windows directory.
Private Function WindowsDirectory() As String
Dim windows_dir As String
Dim length As Long
' Get the Windows directory.
windows_dir = Space$(MAX_PATH)
length = GetWindowsDirectory(windows_dir, _
Len(windows_dir))
WindowsDirectory = Left$(windows_dir, length)
End Function
' Return the Windows directory's drive letter.
Private Function SystemDrive() As String
SystemDrive = Left$(WindowsDirectory(), 1)
End Function
|
|
(Based on advice from Michael Hålling posted to the VB Helper Q and A forum http://www.topica.com/lists/VBHelperQA/read.)
|
|
|
|
|
|