检测 VB.NET 中的PC制造商



是否可以在 VB.NET 中检测到PC的OEM制造商?不是电脑的型号,只有戴尔、惠普、联想、宏碁、帕卡德贝尔等等?

来自您的 BIOS 的响应可能不是预期的,但您可以尝试这样做

Sub Main()
    Dim result = GetBiosProperty("Manufacturer")
    Console.WriteLine(result)
End Sub
Function GetBiosProperty(wmiProperty as string)
    Dim result = string.Empty
    Dim mc = new System.Management.ManagementClass("Win32_BIOS")
    Dim moc = mc.GetInstances()
    for each mo in moc
       if mo(wmiProperty) IsNot Nothing Then
           result = mo(wmiProperty).ToString()
           Exit For
       End If
    Next
    return result.Trim()
End Function

请注意,此代码需要引用 System.Management.dll 和导入 System.Management 命名空间。

这个网站告诉你如何改变它,但相关键在下面。 http://www.techrepublic.com/blog/user-support/change-the-oem-information-in-the-windows-system-properties-panel-to-your-own/

注册表项:

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionOEMInformation

价值:

Manufacturer

这个问题有使用 .NET 读取注册表的建议:.net 注册表读取写入

最新更新