네크
2014.03.17 23:45:52
*: Imports Microsoft.VisualBasic.Devices
Imports System.Management
Public Class Form1
Enum InfoTypes
OperatingSystemName
ProcessorName
AmountOfMemory
VideocardNmae
VideocardMem
End Enum
Public Function Getinfo(ByVal InfoType As InfoTypes) As String
Dim Info As New ComputerInfo : Dim Value, vganame, proc As String
Dim searcher As New Management.ManagementObjectSearcher("root\CIMV2", "SELECT * FROM win32_VideoController")
Dim searcher1 As New Management.ManagementObjectSearcher("SElLECT * FROM win32_Processor")
If InfoType = InfoTypes.OperatingSystemName Then
Value = Info.OSFullName
ElseIf InfoType = InfoTypes.ProcessorName Then
For Each queryObjet As ManagementObject In searcher1.Get
proc = queryObjet.GetPropertyValue("name").ToString
Next
Value = proc
ElseIf InfoType = InfoTypes.AmountOfMemory Then
Value = Math.Round((((CDbl(Convert.ToDouble(Val(Info.TotalPhysicalMemory))) / 1024)) / 1024), 2) & "MB"
ElseIf InfoType = InfoTypes.VideocardNmae Then
For Each queryObjet As ManagementObject In searcher1.Get
vganame = queryObjet.GetPropertyValue("name").ToString
Next
Value = vganame
ElseIf InfoType = InfoTypes.VideocardMem Then
For Each queryObjet As ManagementObject In searcher1.Get
vgamem = queryObjet.GetPropertyValue("name").ToString
Next
Value = Math.Round((((CDbl(Convert.ToDouble(Val(vgamem))) / 1024)) / 1024), 2) & "MB"
End If
Return Value
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ComboBox2.SelectedItem = 0 Then
MsgBox(Getinfo(InfoTypes.OperatingSystemName))
ElseIf ComboBox2.SelectedItem = 1 Then
MsgBox(Getinfo(InfoTypes.ProcessorName))
ElseIf ComboBox2.SelectedItem = 2 Then
MsgBox(Getinfo(InfoTypes.AmountOfMemory))
ElseIf ComboBox2.SelectedItem = 3 Then
MsgBox(Getinfo(InfoTypes.VideocardNmae))
ElseIf ComboBox2.SelectedItem = 4 Then
MsgBox(Getinfo(InfoTypes.VideocardMem))
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox2.SelectedIndex = 0
Dim dirs() As String = System.IO.Directory.GetLogicalDrives
Dim i As Integer
For i = dirs.GetLowerBound(0) To dirs.GetUpperBound(0)
ComboBox1.Items.Add(dirs(i))
Next
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Try
MsgBox("Free Space : " & Math.Round((((CDbl(Convert.ToDouble(Val(My.Computer.FileSystem))) / 1024)) / 1024) / 1024, 2) & "GB" & vbNewLine &
"Total space : " & Math.Round((((CDbl(Convert.ToDouble(Val(My.Computer.FileSystem))) / 1024)) / 1024) / 1024, 2) & "GB")
Catch ex As Exception
MsgBox("No Hard Drive Partition Selected")
End Try
End Sub
End Class