VB.NET注册表项不存在.NET Win7 x64 [英] VB.NET Registry Key Does Not Exist .NET Win7 x64
问题描述
Public Function sequence() As Byte()
Dim r As RegistryKey
Dim return_value As Byte()
r = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,_
RegistryView.Registry64)
r.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion",_
False,_
Security.AccessControl.RegistryRights.QueryValues)
return_value = r.GetValue("DigitalProductID", {})
Return return_value
End Function
为什么上面的代码返回NULL/值不存在?我曾在WMI编程中尝试过Impersonate等.
我要做的就是在Visual Basic Express 2010中将Digital Product ID作为Byte()数组返回给我(AnyCPU编译.我打算将其添加到DLL).在x86 Windows环境中,这当然很简单.
任何帮助将是巨大的.如果您可以使用C#进行操作,那么我总是可以将其转换为VB.NET
这是我所做的.
Why does the above code return NULL/Value does not exist? I have tried Impersonate etc.. in WMI programming.
All I would like to do is get the Digital Product ID return to me as a Byte() array in Visual Basic Express 2010 (AnyCPU compile. As I intend to add this to a DLL). This is of course simple in a x86 Windows enviroment.
Any help would be great. If you can do it in C# then I can always convert it over to VB.NET
Here is what I have Done.
Google for over 2 days.
WMI Impersonate (With the Set oReg, VBE 2010 freaks and removes the SET)
Setting Secuitry Permissions
Changing registry view to Default/32 and 64.
我完全不知所措.因此,任何帮助都会很棒.
干杯
I am at a complete loss. So any help would be great.
Cheers
推荐答案
尝试以下代码:
Try the following code:
const string queryString = "SELECT SerialNumber FROM Win32_OperatingSystem";
string productId = (from ManagementObject managementObject in new ManagementObjectSearcher(queryString).Get()
from PropertyData propertyData in managementObject.Properties
where propertyData.Name == "SerialNumber"
select (string)propertyData.Value).FirstOrDefault();
Console.WriteLine(productId);
这篇关于VB.NET注册表项不存在.NET Win7 x64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!