Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleGet the Windows and System directories
DescriptionThis example shows how to get the Windows and system directories in Visual Basic 6. The program uses the GetSystemDirectory and GetWindowsDirectory API functions.
Keywordssystem directory, windows directory
CategoriesWindows, Files and Directories
 
This program demonstrates the GetSystemDirectory and GetWindowsDirectory API functions.
 
Private Sub Form_Load()
Dim buf As String * 256
Dim return_len As Long
Dim wid1 As Single
Dim wid2 As Single

    return_len = GetSystemDirectory(buf, Len(buf))
    lblSystemDirectory.Caption = Left$(buf, return_len)

    return_len = GetWindowsDirectory(buf, Len(buf))
    lblWindowsDirectory.Caption = Left$(buf, return_len)

    wid1 = lblWindowsDirectory.Left + _
        lblWindowsDirectory.Width + Label1(0).Left
    wid2 = lblSystemDirectory.Left + _
        lblSystemDirectory.Width + Label1(0).Left
    If wid1 > wid2 Then
        Width = Width - ScaleWidth + wid1
    Else
        Width = Width - ScaleWidth + wid2
    End If
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated