Search code examples
c++windowswinapishell-extensions

How to check total number ShellIconOverLayIdentifers installed in a computer using C++


I need to check the total number ShellIconOverLayIdentifers installed in a computer programmatically using C++ and win32 API.

Can I check the identifiers under the below path to get the total count?

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\ShellIconOverlayIdentifiers

Solution

  • You can use RegQueryInfoKey

    This code is tested and working:

    #include "stdafx.h"
    #include <windows.h>
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        LSTATUS lStat;
        HKEY hKey;
        DWORD dwSubKeys;
    
        lStat = RegOpenKeyExA(
                HKEY_LOCAL_MACHINE, 
                "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\explorer\\ShellIconOverlayIdentifiers",
                0L, KEY_READ | KEY_WOW64_64KEY, &hKey);
        if(lStat == ERROR_SUCCESS)
        {
            lStat = RegQueryInfoKeyA(
                hKey, NULL, NULL, NULL, 
                &dwSubKeys, NULL, NULL, 
                NULL, NULL,NULL, NULL, NULL);
    
            printf_s("Subkeys : %u\n", dwSubKeys);
    
    
            RegCloseKey(hKey);
        }
        return 0;
    }
    

    UPDATE:

    Based on JChan's investigation, following key access is required on 64-bit version of windows:

    KEY_READ | KEY_WOW64_64KEY
    

    Example