Get Windows serial number Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Marcus Frenkel
Experienced Solver
Experienced Solver
Posts: 79
Joined: Thu Sep 25, 2008 12:14 am

Get Windows serial number

Post by Marcus Frenkel »

Hi,

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

Marcus
mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Re: Get Windows serial number

Post 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
chris_bern
Earned some good credits
Earned some good credits
Posts: 125
Joined: Wed Mar 05, 2008 3:30 pm

Re: Get Windows serial number

Post 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
computerquip
Experienced Solver
Experienced Solver
Posts: 72
Joined: Fri Feb 20, 2009 7:13 pm
Location: $(#wx)\src

Re: Get Windows serial number

Post by computerquip »

:P Two conflicting posts that say the opposite.
Marcus Frenkel
Experienced Solver
Experienced Solver
Posts: 79
Joined: Thu Sep 25, 2008 12:14 am

Re: Get Windows serial number

Post 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?
chris_bern
Earned some good credits
Earned some good credits
Posts: 125
Joined: Wed Mar 05, 2008 3:30 pm

Re: Get Windows serial number

Post 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
Marcus Frenkel
Experienced Solver
Experienced Solver
Posts: 79
Joined: Thu Sep 25, 2008 12:14 am

Post by Marcus Frenkel »

That's fine enough since I only need unique ID of the Windows installation. Thanks to all for the help.
Post Reply