Private Sub GetEnvironment_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetEnvironment.Click
' set the cursor to an hourglass
Me.Cursor = Cursors.WaitCursor
With EnvironmentListView
' clear the ListView of any existing items
.Items.Clear()
' Create a ListView variable
Dim lvi As ListViewItem
' Create a new instance of the ListItem variable
' and re-use it for each property you add to the ListView
lvi = New ListViewItem
With lvi
.Text = "Current Directory"
.SubItems.Add(Environment.CurrentDirectory)
End With
.Items.Add(lvi)
lvi = New ListViewItem
With lvi
.Text = "Machine Name"
.SubItems.Add(Environment.MachineName)
End With
.Items.Add(lvi)
lvi = New ListViewItem
With lvi
.Text = "OS Version"
' NOTE: Call the ToString method to convert the number
' to a string variable for display
.SubItems.Add(Environment.OSVersion.ToString)
End With
.Items.Add(lvi)
lvi = New ListViewItem
With lvi
.Text = "System Directory"
.SubItems.Add(Environment.SystemDirectory)
End With
.Items.Add(lvi)
lvi = New ListViewItem
With lvi
.Text = "Ticks since last shutdown"
.SubItems.Add(Environment.TickCount)
End With
.Items.Add(lvi)
lvi = New ListViewItem
With lvi
.Text = "User Domain Name"
.SubItems.Add(Environment.UserDomainName)
End With
.Items.Add(lvi)
lvi = New ListViewItem
With lvi
.Text = "User Name"
'Note: Call the ToString method to convert the number
' to a string variable for display
.SubItems.Add(Environment.UserName)
End With
.Items.Add(lvi)
lvi = New ListViewItem
With lvi
.Text = "User DomainName"
.SubItems.Add(Environment.Version.ToString)
End With
.Items.Add(lvi)
End With
Me.Cursor = Cursors.Default
End Sub
Private Sub GetDrives_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetDrives.Click
' Set the Cursor to an Hourglass
Me.Cursor = Cursors.WaitCursor
' Clear the ListView
EnvironmentListView.Items.Clear()
'Declare a string array called logicalDrivers and call the
' GetLogicalDrivers method of the Environment class
Dim LogicalDrives As String() = Environment.GetLogicalDrives()
'Create a string variable so we can loop
'trough the array using For Each
Dim Drive As String
'Create a ListView Item variable
Dim lvi As ListViewItem
'Look for each drive variable in the logicalDrives string array
For Each Drive In logicalDrives
With EnvironmentListView
lvi = New ListViewItem
With lvi
.Text = "Drive Letter"
.SubItems.Add(Drive)
End With
.Items.Add(lvi)
End With
Next Drive
Me.Cursor = Cursors.Default
End Sub
Private Sub GetSpecialFolders_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetSpecialFolders.Click
' set the cursor to an hourglass
Me.Cursor = Cursors.WaitCursor
With EnvironmentListView.Items
'clear the ListViewItems
.Clear()
' Add each property into the ListView
.Add("Program Files Folder").SubItems.Add _
(Environment.GetFolderPath _
(Environment.SpecialFolder.ProgramFiles))
.Add("Application Data").SubItems.Add _
(Environment.GetFolderPath _
(Environment.SpecialFolder.ApplicationData))
.Add("Personal Folder").SubItems.Add _
(Environment.GetFolderPath _
(Environment.SpecialFolder.Personal))
.Add("Local Application Data Folder").SubItems.Add _
(Environment.GetFolderPath _
(Environment.SpecialFolder.ApplicationData))
End With
Me.Cursor = Cursors.Default
End Sub