NameIs it possible to detect the graphics card name from .Net code? Yes it is possible using WMI. But you need to reference the System.Management and import it.
Using WMI to get the Graphics Card Name
WMI can be used to query a lot of information about hardware and Operating systems related information. ManagementObjectSearcher can be used to query the data. It accepts two parameters. The first parameter is to tell which section to search called as scope. And the second parameter is the actual query almost similar to SQL query. Using the Get method of ManagementObjectSearcher will give the result set in a collection.
Source Code
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 _
("root\CIMV2", "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
For a formated source code refer VB.Net Code to Detect Video Card Name
Monday, January 24, 2011
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment