Jump to content
Vlachs

[VB.NET] WMI Acces

Recommended Posts

Posted

Imports System.Management
Public Class Resources
Public Shared Function WMI(ByVal location As String, ByVal query_term As String, ByVal value As String) As String
Dim Result = String.Empty
Try
Dim WmiSelect As New ManagementObjectSearcher(location, query_term)
For Each WmiResults As ManagementObject In WmiSelect.Get()
Result = WmiResults.GetPropertyValue(value).ToString
If (Not String.IsNullOrEmpty(Result)) Then
Exit For
End If
Next
Catch err As ManagementException
MessageBox.Show(err.Message)
End Try
Return Result
End Function
End Class

Exemplu:

 Label1.Text = "Video Card: " & Resources.WMI("root\CIMV2", "SELECT * FROM Win32_VideoController", "Name")
Label2.Text = "Processor: " & Resources.WMI("root\CIMV2", "SELECT * FROM Win32_Processor", "Name")

Trebuie sa adaugati System.Management ca referinta inainte de a putea accesa datele.

  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...