wxRegKey & subkeys Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
albinoblacksheep
Earned a small fee
Earned a small fee
Posts: 11
Joined: Tue Mar 28, 2017 4:59 pm

wxRegKey & subkeys

Post by albinoblacksheep »

Hi all,

I am actually struggeling with subkeys underneath HKLM\Software:

The following code

Code: Select all

    // This assumes that the key already exists, use HasSubKey() to check
    // for the key existence if necessary.
    wxRegKey key(wxRegKey::HKLM, "Software");

    // Create a new value "MyValue" and set it to 12.
    //key.SetValue("InstallLocation", 12);
    // Read the value back.
    //long value;
    //key.QueryValue("SOFTWARE", &value);
    //wxLogMessage("Registry value: %ld", value);
    // Enumerate the subkeys.
    wxString keyName;
    long index = 0;
    for ( bool cont = key.GetFirstKey(keyName, index);
        cont;
        cont = key.GetNextKey(keyName, index) )
        {
            wxLogMessage("Subkey name: %s", keyName);
        }
returns

Code: Select all

3:14:11: Subkey name: AGEIA Technologies
23:14:11: Subkey name: Arduino
23:14:11: Subkey name: Atmel
23:14:11: Subkey name: AVM
23:14:11: Subkey name: Blackmagic Design
23:14:11: Subkey name: Blizzard Entertainment
23:14:11: Subkey name: Caphyon
23:14:11: Subkey name: Google
23:14:11: Subkey name: iDealshare
23:14:11: Subkey name: InstallShield
23:14:11: Subkey name: Intel
23:14:11: Subkey name: ITEAD
23:14:11: Subkey name: Khronos
23:14:11: Subkey name: Macromedia
23:14:11: Subkey name: Microchip
23:14:11: Subkey name: Microsoft
23:14:11: Subkey name: Mobatek
23:14:11: Subkey name: Mozilla
23:14:11: Subkey name: MSI
23:14:11: Subkey name: MSI Remind Manager
23:14:11: Subkey name: Nextcloud GmbH
23:14:11: Subkey name: Norton
23:14:11: Subkey name: NVIDIA Corporation
23:14:11: Subkey name: OBS Studio
23:14:11: Subkey name: ODBC
23:14:11: Subkey name: Overwolf
23:14:11: Subkey name: Realtek
23:14:11: Subkey name: Realtek Semiconductor Corp.
23:14:11: Subkey name: Samsung
23:14:11: Subkey name: SSDIAG
23:14:11: Subkey name: SSScan
23:14:11: Subkey name: Symantec
23:14:11: Subkey name: Ultimaker B.V.
23:14:11: Subkey name: Unwinder
23:14:11: Subkey name: Valve
23:14:11: Subkey name: Volatile
23:14:11: Subkey name: Classes
23:14:11: Subkey name: Clients
23:14:11: Subkey name: Policies
23:14:11: Subkey name: RegisteredApplications
(40 subkeys)

but in regedit I count 46 subkeys under HKLM\Software.
regedit
regedit
Even if I run the code as admin only 40 subkeys are returned.
What I am missing here that some subkeys are swallowed?

BR
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxRegKey & subkeys

Post by doublemax »

From inside a 32 bit application on a 64bit OS you will only "see" the keys inside the "Wow6432Node". Check the entries there, they should match the output of your code.
Use the source, Luke!
albinoblacksheep
Earned a small fee
Earned a small fee
Posts: 11
Joined: Tue Mar 28, 2017 4:59 pm

Re: wxRegKey & subkeys

Post by albinoblacksheep »

Sounds plausible. Thanks a lot!

BR
albinoblacksheep
Earned a small fee
Earned a small fee
Posts: 11
Joined: Tue Mar 28, 2017 4:59 pm

Re: wxRegKey & subkeys

Post by albinoblacksheep »

Sorry that I have to reask. As far I understand the documentation I should be able to access the 64bit keys from a 32bit application using WOW64ViewMode_64. However, the following code does not work:

Code: Select all

    wxRegKey key(wxRegKey::HKLM, "Software\\81bfc699-f883-50c7-b674-2483b6baae23",wxIsPlatform64Bit() ? wxRegKey::WOW64ViewMode_64 : wxRegKey::WOW64ViewMode_Default);

    // Enumerate the subkeys.
    wxString keyName;
    long index = 0;
    for ( bool cont = key.GetFirstKey(keyName, index);
        cont;
        cont = key.GetNextKey(keyName, index) )
        {
            wxLogMessage("Subkey name: %s", keyName);
        }
Here it makes also no difference if the code is being executed with admin privileges or not. The machine is running on 64bit, the code is compiled as 32bit (it seems actually to be a horrific task to compile wxwidgets 3.1.3 in 64bit).
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxRegKey & subkeys

Post by doublemax »

Does the "81bfc699-f883-50c7-b674-2483b6baae23" even exist? Without it, the code works for me.
Use the source, Luke!
albinoblacksheep
Earned a small fee
Earned a small fee
Posts: 11
Joined: Tue Mar 28, 2017 4:59 pm

Re: wxRegKey & subkeys

Post by albinoblacksheep »

Yes, as you can see on the screenshot above. That's why I am confused
albinoblacksheep
Earned a small fee
Earned a small fee
Posts: 11
Joined: Tue Mar 28, 2017 4:59 pm

Re: wxRegKey & subkeys

Post by albinoblacksheep »

(And yes, it has values underneath of type REG_SZ)
albinoblacksheep
Earned a small fee
Earned a small fee
Posts: 11
Joined: Tue Mar 28, 2017 4:59 pm

Re: wxRegKey & subkeys

Post by albinoblacksheep »

Found further hints, will investigate further. Problem is error 234 which has nothing to do with my initial problem, thx
Post Reply