'I want to find UUID in my application. Code gives Problem
Following is my code to get UUID of my PC. I'm finding Error. Pls help me to resolve the errors. I'm getting Error on "ManagementObjectSearcher" & "ManagementObject" not defind.
Option Strict On
Imports System
Imports System.Management
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Imports System.Diagnostics
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim readValue As String
Try
Dim searcher As New ManagementObjectSearcher("root\CIMV2",
"SELECT * FROM Win32_ComputerSystemProduct")
For Each queryObj As ManagementObject In searcher.Get()
Console.WriteLine("-----------------------------------")
Console.WriteLine("Win32_ComputerSystemProduct instance")
Console.WriteLine("-----------------------------------")
readValue = "UUID: " & queryObj("UUID")
RichTextBox1.Text = RichTextBox1.Text & Chr(13) & Chr(10) & readValue
Next
Catch err As Exception
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|