繁体   English   中英

为XP,Vista和7获取Windows串行

[英]Get windows serial for XP, Vista and Seven

我正在使用此功能检索Windows XP许可证密钥,但不适用于Vista和Seven。 在这两个Windows版本中如何获得许可证密钥?

Public Function sGetXPKey() As String
    Dim result As String = String.Empty

    Dim RegKey As RegistryKey = _
    Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows NT\CurrentVersion", False)
    Dim bytDPID() As Byte = RegKey.GetValue("DigitalProductID")
    Dim bytKey(14) As Byte
    Array.Copy(bytDPID, 52, bytKey, 0, 15)
    Dim strChar As String = "BCDFGHJKMPQRTVWXY2346789"
    Dim strKey As String = ""

    For j As Integer = 0 To 24
        Dim nCur As Short = 0
        For i As Integer = 14 To 0 Step -1
            nCur = CShort(nCur * 256 Xor bytKey(i))
            bytKey(i) = CByte(Int(nCur / 24))
            nCur = CShort(nCur Mod 24)
        Next
        strKey = strChar.Substring(nCur, 1) & strKey
    Next

    For i As Integer = 4 To 1 Step -1
        strKey = strKey.Insert(i * 5, "-")
    Next

    Return strKey
End Function

建议您不要使用注册表,而不要使用注册表。 具体地, Win32_OperatingSystem如所描述的类这里 在该页面上可以看到一个名为SerialNumber的属性。

页面包含有关如何执行此操作的完整示例(包括说明)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM