Get hardware information such as Graphic Card capabilities

前端 未结 3 1127
萌比男神i
萌比男神i 2020-12-04 00:29

I\'m writing a program that is using a validation of graphic card. I tried using multiple ways; the closest one i found was using:

lblGrapics.Text = infotype         


        
3条回答
  •  长情又很酷
    2020-12-04 01:01

    It is possible to get graphics card info using WMI. You need to reference the System.Management and import it.

    WMI is a great library which contains the details about various components required for the system to operate. Hard Disk Drive related information, processor information, Network components and the list goes on. It is really easy to query the data if you know a little about the data how it is organized.

    You have to use the ManagementObjectSearcher class.

    Example:

    Imports System.Management
    
    
    Public Class Form1
    
    Private Sub Button1_Click(ByVal sender As System.Object, _ByVal e As System.EventArgs) Handles Button1.Click
    
         MsgBox(GetGraphicsCardName())
    End Sub
    
    Private Function GetGraphicsCardName() As String
         Dim GraphicsCardName = String.Empty
         Try
              Dim WmiSelect As New ManagementObjectSearcher _("rootCIMV2", "SELECT * FROM Win32_VideoController")
              For Each WmiResults As ManagementObject In WmiSelect.Get()
                   GraphicsCardName = WmiResults.GetPropertyValue("Name").ToString
                   If (Not String.IsNullOrEmpty(GraphicsCardName)) Then
                        Exit For
                   End If
              Next
         Catch err As ManagementException
              MessageBox.Show(err.Message)
         End Try
         Return GraphicsCardName
    End Function
    End Class
    

    Source

提交回复
热议问题