如何在Windows 7 64位中获取productId [英] how to get productId in windows 7 64 bit

查看:510
本文介绍了如何在Windows 7 64位中获取productId的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

hello,
How to get ProductId in windows 7 64 bit using C++?

推荐答案

许多很多,非常感谢Richard的宝贵见识.

我已经修改了旧的代码,以使
Many, many, MANY thanks to Richard for his invaluable insight.

I''ve modded the old code I have such that
ReturnStatus = RegOpenKeyEx( HKEY_LOCAL_MACHINE, RegKey, 0, KEY_QUERY_VALUE, &Registry );


成为


becomes

ReturnStatus = RegOpenKeyEx( HKEY_LOCAL_MACHINE, RegKey, 0, KEY_QUERY_VALUE | KEY_WOW64_64KEY, &Registry );



我现在可以高兴地报告说,适用于XP的解密功能生成的ProductKey与其他可用解决方案(MagicJellyBean KeyFinder,WinKeyFinder,ProduKey-64)相同.

女士们和男士们在这里:



I can now happily report that the decrypt function that works for XP generates the same ProductKey as other available solutions (MagicJellyBean KeyFinder, WinKeyFinder, ProduKey-64).

Here you go ladies and gents:

char* DecodeMicrosoftKey( BYTE* digitalProductId )
{

    /* NULL is a valid byte value, so check for it. */
    if ( digitalProductId )
    {
        /* Offset first value to 34H. */
        const int keyStartIndex = 52;
        /* Offset last value to 43H. */
        const int keyEndIndex = keyStartIndex + 15;
        /* Valid Product Key Characters. */
        char digits[] =
        {
            'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R',
            'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9',
        };
        /* Length of decoded product key. */
        const int decodeLength  =   29;
        /* Length of decoded key in byte-form (each byte = 2 chars). */
        const int decodeStringLength = 15;
        /* Array to contain decoded key. */
        char* pDecodedChars = new char[ decodeLength + 1 ];

        memset( pDecodedChars, 0, decodeLength + 1 );

        /* Extract byte 52 to 67 inclusive. */
        byte hexPid[ keyEndIndex - keyStartIndex + 1 ];

        for ( int i = keyStartIndex; i <= keyEndIndex; i++ )
        {
            hexPid[ i - keyStartIndex ] = digitalProductId[ i ];
        }

        for ( int i = decodeLength - 1; i >= 0; i-- )
        {
            /* Every 6th character is a seperator. */
            if ( ( i + 1 ) % 6 == 0 )
            {
                *( pDecodedChars + i ) = '-';
            }
            else
            {
                /* Do the actual decoding. */
                int digitMapIndex = 0;
                for ( int j = decodeStringLength - 1; j >= 0; j-- )
                {
                    int byteValue = ( digitMapIndex << 8 ) | hexPid[ j ];
                    hexPid[ j ] = ( byte )( byteValue / 24 );
                    digitMapIndex = byteValue % 24;
                    *( pDecodedChars + i ) = digits[ digitMapIndex ];
                }
            }
        }
        /*
         * Return the decoded product key.
         */
        return pDecodedChars;
    }
    /* digitalProductID was passed as a NULL value, return NULL. */
    else
    {
        return NULL;
    }
}


您可以从注册表项中读取它
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId.

[更新]
也可以使用WMI Win32_OperatingSystem类(SerialNumber成员)[ ^ ]
[/UPDATE]
You can read it from the registry key
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId.

[UPDATE]
The WMI Win32_OperatingSystem class can be also used (SerialNumber member) [^]
[/UPDATE]


我会说出与Jochen在答案1中所做的相同的话,但是_似乎这个任务并不那么简单...

我编写了一个程序来检索各种Windows安装统计信息:
产品名称
产品编号
产品密钥
注册到
服务包
Build No

我的程序尝试从答案1中提到的键中读取内容.我遇到的问题是,该程序在Win2003(x86)和WinXp(x86)中可以正常工作.

现在,当我在Win7 x64下运行相同的可执行文件时,产品ID,产品密钥,服务包信息都将以空字符串形式返回. 注册到"字段始终填充有"Microsoft"

最有趣的是,注册表项HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion中的任何地方都不存在字符串"Microsoft"!
果然,使用RegEdit.exe浏览到提到的键确实可以提供预期的信息..

(是的!我确实在用户和管理员模式下都尝试了该程序-结果相同)

从头开始-希望有个好的答案.笔记本电脑底部的Windows贴纸不再清晰可见.该操作系统似乎将从重新安装中受益.问题?在(重新)安装过程中,没有产品密钥返回使用. :sad:

虽然,我想我可以在通过密钥解密功能运行数据之前,简单地复制在RegEdit中读取的数据.

我会尝试并报告结果.


只需再次在WinXP中检查程序(在VirtualBox仿真器中运行),即可正常工作.通过仔细检查,我可以看到在XP中,此字段(DigitalProductId)包含0xA4字节.在Win7(x64)中,此字段现在包含0x4F0字节.

我还应该提到,即使在编辑此字段时,也不能简单地选择所有数据并将其复制-即使右键单击会弹出一个包含剪切和复制的菜单,Windows也不会将任何内容复制到剪贴板.复制绝对不会执行任何操作,剪切会删除文本,但不会将其复制到剪贴板. (在XP和Win7中行为相同)


我开始怀疑操作系统会先检查谁正在尝试读取特定的注册表项,然后再将返回的结果定制为适合".

真的希望我不必在DickSmith,Acer或Microsoft的耳朵上咀嚼.
I would have said the same thing as Jochen did in Answer 1, _however_ it seems that this task is not quite so simple...

I coded a program that retrieves assorted windows installation stats:
Product Name
Product Id
Product Key
Registered To
Service Pack
Build No

My program attempts to read from the key mentioned in Answer 1. The problem I have, is that this program worked fine in Win2003(x86) and WinXp(x86).

Now, when I run the same executable under Win7 x64, Product ID, Product Key, Service Pack information are all returned as empty strings. The "Registered To" field is always filled with "Microsoft"

The most interesting thing is that nowhere in the registry key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion does the string "Microsoft" exist!!!!

Sure enough, browsing to the mentioned key using RegEdit.exe does present the expected information..

(And yes! I did try the program in both User and Admin mode - same result)

Scratches head - hopes for good answer. The Windows sticker on the bottom of my laptop is no longer legible. The OS seems like it would benefit from being re-installed. Problem? No Product Key is returned to use during the (re)installation. :sad:

Although, I guess I could simply copy the data as read in RegEdit before running it through the key decryption function.

I''ll try it and report results.


Just checked the program again in WinXP (running inside VirtualBox emulator) -- it works just fine. On closer examination, I can see that in XP, this field(DigitalProductId) contains 0xA4 bytes. While in Win7(x64), this field is now contains 0x4F0 bytes.

I should also mention that even when editing this field, one cannot simply select all of the data and copy it - windows copies nothing to the clipboard, even though right-click brings up a menu that includes cut and copy. Copy does absolutely nothing, Cut deletes the text but doesn''t copy it to the clipboard. (same behaviour in XP and Win7)


I''m beginning to suspect that the OS checks who is trying to read particular registry keys, before tailoring the returned result to ''suit''.

Really hope I don''t have to chew on someone''s ear at DickSmith, Acer or Microsoft


这篇关于如何在Windows 7 64位中获取productId的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆