비베닷넷에서 System.Windows.Forms.SystemInformation 을 사용하여 윈도우정보나 시스템의 일부 정보를 취득하여 값을 출력시켜주는 클래스입니다.
프로그래밍 전체소스입니다.
마이크로 소프트 공식 홈페이지 링크
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.systeminformation?view=netcore-3.1
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Reflection
Imports System.Windows.Forms
Public Class SystemInfoBrowserForm
Inherits System.Windows.Forms.Form
Private listBox1 As System.Windows.Forms.ListBox
Private textBox1 As System.Windows.Forms.TextBox
Public Sub New()
Me.SuspendLayout()
InitForm()
' Add each property of the SystemInformation class to the list box.
Dim t As Type = GetType(System.Windows.Forms.SystemInformation)
Dim pi As PropertyInfo() = t.GetProperties()
Dim i As Integer
For i = 0 To pi.Length - 1
listBox1.Items.Add(pi(i).Name)
Next i
textBox1.Text = "The SystemInformation class has " + pi.Length.ToString() + " properties." + ControlChars.CrLf
' Configure the list item selected handler for the list box to invoke a
' method that displays the value of each property.
AddHandler listBox1.SelectedIndexChanged, AddressOf listBox1_SelectedIndexChanged
Me.ResumeLayout(False)
End Sub
Private Sub listBox1_SelectedIndexChanged(sender As Object, e As EventArgs)
' Return if no list item is selected.
If listBox1.SelectedIndex = - 1 Then
Return
End If
' Get the property name from the list item.
Dim propname As String = listBox1.Text
If propname = "PowerStatus" Then
' Cycle and display the values of each property of the PowerStatus property.
textBox1.Text += ControlChars.CrLf + "The value of the PowerStatus property is:"
Dim t As Type = GetType(System.Windows.Forms.PowerStatus)
Dim pi As PropertyInfo() = t.GetProperties()
Dim i As Integer
For i = 0 To pi.Length - 1
Dim propval As Object = pi(i).GetValue(SystemInformation.PowerStatus, Nothing)
textBox1.Text += ControlChars.CrLf + " PowerStatus." + pi(i).Name + " is: " + propval.ToString()
Next i
Else
' Display the value of the selected property of the SystemInformation type.
Dim t As Type = GetType(System.Windows.Forms.SystemInformation)
Dim pi As PropertyInfo() = t.GetProperties()
Dim prop As PropertyInfo = Nothing
Dim i As Integer
For i = 0 To pi.Length - 1
If pi(i).Name = propname Then
prop = pi(i)
Exit For
End If
Next i
Dim propval As Object = prop.GetValue(Nothing, Nothing)
textBox1.Text += ControlChars.CrLf + "The value of the " + propname + " property is: " + propval.ToString()
End If
End Sub
Private Sub InitForm()
' Initialize the form settings
Me.listBox1 = New System.Windows.Forms.ListBox()
Me.textBox1 = New System.Windows.Forms.TextBox()
Me.listBox1.Anchor = CType(System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right, System.Windows.Forms.AnchorStyles)
Me.listBox1.Location = New System.Drawing.Point(8, 16)
Me.listBox1.Size = New System.Drawing.Size(172, 496)
Me.listBox1.TabIndex = 0
Me.textBox1.Anchor = CType(System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right, System.Windows.Forms.AnchorStyles)
Me.textBox1.Location = New System.Drawing.Point(188, 16)
Me.textBox1.Multiline = True
Me.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.textBox1.Size = New System.Drawing.Size(420, 496)
Me.textBox1.TabIndex = 1
Me.ClientSize = New System.Drawing.Size(616, 525)
Me.Controls.Add(Me.textBox1)
Me.Controls.Add(Me.listBox1)
Me.Text = "Select a SystemInformation property to get the value of"
End Sub
<STAThread()> _
Shared Sub Main()
Application.Run(New SystemInfoBrowserForm())
End Sub
End Class
티스토리에 소스코드를 붙여넣기 하면 탭이 없어지거나 붙여넣기가 안되는 현상이 있어서 탭 모두 삭제하고 줄바꿈 태그로만 작성하였습니다. 보기가 상당히 불편한데 위 링크에서 확인하세요.
툴박스 컨트롤은 리스트박스와 텍스트박스가 필요합니다.
폼을 실행하면 리스트박스에 프로퍼티이름이 추가됩니다.
리스트박스에서 항목을 선택하면 값이 텍스트박스에 출력됩니다.
아래 스크린샷은 리스트박스, 텍스트박스 크기와 위치만 별도로 수정한 결과입니다.
프로퍼티이름 목록
ActiveWindowTrackingDelay
ArrangeDirection
ArrangeStartingPosition
BootMode
Border3DSize
BorderMultiplierFactor
BorderSize
CaptionButtonSize
CaptionHeight
CaretBlinkTime
CaretWidth
ComputerName
CursorSize
DbcsEnabled
DebugOS
DoubleClickSize
DoubleClickTime
DragFullWindows
DragSize
FixedFrameBorderSize
FontSmoothingContrast
FontSmoothingType
FrameBorderSize
HighContrast
HorizontalFocusThickness
HorizontalResizeBorderThickness
HorizontalScrollBarArrowWidth
HorizontalScrollBarHeight
HorizontalScrollBarThumbWidth
IconHorizontalSpacing
IconSize
IconSpacingSize
IconVerticalSpacing
IsActiveWindowTrackingEnabled
IsComboBoxAnimationEnabled
IsDropShadowEnabled
IsFlatMenuEnabled
IsFontSmoothingEnabled
IsHotTrackingEnabled
IsIconTitleWrappingEnabled
IsKeyboardPreferred
IsListBoxSmoothScrollingEnabled
IsMenuAnimationEnabled
IsMenuFadeEnabled
IsMinimizeRestoreAnimationEnabled
IsSelectionFadeEnabled
IsSnapToDefaultEnabled
IsTitleBarGradientEnabled
IsToolTipAnimationEnabled
KanjiWindowHeight
KeyboardDelay
KeyboardSpeed
MaxWindowTrackSize
MenuAccessKeysUnderlined
MenuBarButtonSize
MenuButtonSize
MenuCheckSize
MenuFont
MenuHeight
MenuShowDelay
MidEastEnabled
MinimizedWindowSize
MinimizedWindowSpacingSize
MinimumWindowSize
MinWindowTrackSize
MonitorCount
MonitorsSameDisplayFormat
MouseButtons
MouseButtonsSwapped
MouseHoverSize
MouseHoverTime
MousePresent
MouseSpeed
MouseWheelPresent
MouseWheelScrollDelta
MouseWheelScrollLines
NativeMouseWheelSupport
Network
PenWindows
PopupMenuAlignment
PowerStatus
PrimaryMonitorMaximizedWindowSize
PrimaryMonitorSize
RightAlignedMenus
ScreenOrientation
Secure
ShowSounds
SizingBorderWidth
SmallCaptionButtonSize
SmallIconSize
TerminalServerSession
ToolWindowCaptionButtonSize
ToolWindowCaptionHeight
UIEffectsEnabled
UserDomainName
UserInteractive
UserName
VerticalFocusThickness
VerticalResizeBorderThickness
VerticalScrollBarArrowHeight
VerticalScrollBarThumbHeight
VerticalScrollBarWidth
VirtualScreen
WorkingArea
'프로그래밍' 카테고리의 다른 글
예약시간에 프로그램 시작, 종료, 모니터끄기 WindowexeTaskOnOff (0) | 2021.03.03 |
---|---|
공인아이피 및 로컬아이피 확인하는 프로그램 (0) | 2021.02.24 |
vb.net 메세지박스에 타이머 붙여서 자동으로 닫기 코드 (2) | 2020.06.03 |
vb.net 콘솔 FreeConsole AllocConsole 재사용하기 (0) | 2020.06.01 |
C# 알트탭 눌렀을 때 프로그램 목록에 나오지 않게 하기 (8) | 2020.05.27 |