|
-
Jun 17th, 2000, 09:54 PM
#1
Thread Starter
Hyperactive Member
How can I get the windows Directory?
-
Jun 17th, 2000, 10:07 PM
#2
Use the GetWindowsDirectory API.
-
Jun 18th, 2000, 12:37 AM
#3
Code:
Public Function DirExists(ByVal strDirName As String) As Integer
Dim strDummy As String
On Error Resume Next
If Right$(strDirName, 1) <> "\" Then
strDirName = strDirName & "\"
End If
strDummy = Dir$(strDirName & "*.*", vbDirectory)
DirExists = Not (strDummy = vbNullString)
Err = 0
End Function
Usage:
If DirExists("C:\Windows\") Then
'do whatever
End If
-
Jun 18th, 2000, 12:45 AM
#4
Lively Member
Windows dir using API...
To get the path to the windows folder, as Megatron said, use the GetWindowsDirectory API function. Check out thte following sample code. The class file is called Windows.cls.
Code:
'Windows.cls
Option Explicit
Private Declare Function GetWindowsDirectory Lib _
"kernel32" Alias "GetWindowsDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Long) _
As Long
Public Function GetWinDir() As String
Dim strPath As String
Dim lngRet As Long
strPath = Space(256) 'String buffer
lngRet = GetWindowsDirectory(strPath, 256)
strPath = Left(strPath, lngRet) 'Trim the string
GetWinDir = strPath 'Return the path
End Function
Now, in a form or module, put the following code to get the windows path:
Code:
Dim win As New Windows
'Display the windows directory
Msgbox win.GetWinDir
Hope this helps!
Latrz
REM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|