Page 1 of 1

Get Windows serial number

Posted: Wed Mar 18, 2009 10:40 pm
by Marcus Frenkel
Hi,

Is there any wx function to get the registration serial number of the running MS Windows OS?

Marcus

Re: Get Windows serial number

Posted: Wed Mar 18, 2009 10:54 pm
by mc2r
Marcus Frenkel wrote:Hi,

Is there any wx function to get the registration serial number of the running MS Windows OS?

Marcus
No, you will have to use system specific api's. To keep it as portable as possible wrap the code in ifdefs...

Code: Select all

#ifdef WIN32
    //win32 code to check serial number
#endif
-Max

Re: Get Windows serial number

Posted: Fri Mar 20, 2009 11:27 am
by chris_bern
Marcus Frenkel wrote:Is there any wx function to get the registration serial number of the running MS Windows OS?
Under Windows you can use:

Code: Select all

wxRegKey *key = new wxRegKey("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion");

key->QueryValue("ProductId", &value);
Chris

Re: Get Windows serial number

Posted: Fri Mar 20, 2009 12:00 pm
by computerquip
:P Two conflicting posts that say the opposite.

Re: Get Windows serial number

Posted: Fri Mar 20, 2009 5:12 pm
by Marcus Frenkel
chris_bern wrote:

Code: Select all

wxRegKey *key = new wxRegKey("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion");
Solution for MSW will be fine enough. Is the serial number always stored in that place of the registry regardless of the Microsoft Windows version?

Re: Get Windows serial number

Posted: Fri Mar 20, 2009 5:31 pm
by chris_bern
Marcus Frenkel wrote:
chris_bern wrote:

Code: Select all

wxRegKey *key = new wxRegKey("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion");
Solution for MSW will be fine enough. Is the serial number always stored in that place of the registry regardless of the Microsoft Windows version?
Win 95 - Win XP should store the product key in the same location. The following location should be more portable: "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion".

On Vista, the same key location contains the product ID number, not the actual product key used for installation, the later is encrypted.

Chris

Posted: Fri Mar 20, 2009 5:35 pm
by Marcus Frenkel
That's fine enough since I only need unique ID of the Windows installation. Thanks to all for the help.