dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: How do I get Windows System Directory?

  1. #1
    Join Date
    Dec 1999
    Location
    Delhi, India
    Posts
    51

    How do I get Windows System Directory?

    How do I get the complete system directory path on all windows platforms?
    I mean:
    c:\windows\system
    d:\winnt\system32
    etc.

    Thanx
    Manish

  2. #2
    Join Date
    Sep 2001
    Location
    IL, USA
    Posts
    1,090
    Code:
    Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal uSize As Long) As Long
    Private Sub Command1_Click()
       Dim strDir As String, MaxLen As Long, RetVal As Long
       MaxLen = 255
       strDir = Space(MaxLen)
       RetVal = GetSystemDirectory(strDir, MaxLen)
       If RetVal > 0 Then
          MsgBox "Windows System Directory is: " & Left(strDir, RetVal), vbInformation
       Else
          MsgBox "Could not retrieve Windows System Directory path!", vbExclamation
       End If
    End Sub

  3. #3
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167
    Code:
    Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    Private Const MAX_PATH = 260
    
    Sub GetSystemDir()
      dim szPath as String, nLen as Long
      szPath = String(MAX_PATH+1, 0)
    
      nLen = MAX_PATH + 1
      nLen = GetSystemDirectory(szPath, nLen)
      msgbox "System Dir: " & left(szPath, nLen)
    End Sub
    Good Luck,
    -Cool Bizs

  4. #4
    Join Date
    Dec 1999
    Location
    Delhi, India
    Posts
    51
    Thanx!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)