0

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
Xearinox
  • 3,224
  • 2
  • 24
  • 38
JChan
  • 1,411
  • 4
  • 24
  • 34
  • 1
    IIRC that lets you know how many handlers, but not how many each they're using. (I came to the opinion some time ago that the answer is always "too many" and to do something else if at all possible, but "if at all possible" doesn't always work out, of course). – Jon Hanna Aug 15 '12 at 19:20
  • Thanks jon for the valid informations – JChan Aug 15 '12 at 19:59
  • Not necessarily valid, hence making it a comment with "IIRC" rather than an answer. – Jon Hanna Aug 15 '12 at 20:07

1 Answers1

1

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

rkosegi
  • 14,165
  • 5
  • 50
  • 83
  • @rkosgi thanks for your help, I have 10 keys under ShellIconOverlayIdentifiers, but the above code returns the number of sub keys is 2. If I give the path till explorer, its returning the more sub keys but not all. I am trying to find out why its not getting all sub keys – JChan Aug 15 '12 at 20:10
  • @JChan : check my updated answer.This code works well.It shows 11 in my case. – rkosegi Aug 15 '12 at 20:26
  • I tested your code in windows XP it worked. But win7 64 bit, the same code didn't work. – JChan Aug 15 '12 at 20:47
  • @JChan : This is probably related to UAC.You need to run program as adminstrator or try to change 4th parameter of RegOpenKeyExA from KEY_ALL_ACCESS to KEY_QUERY_VALUE.BTW I'm run on Windows 7 too. – rkosegi Aug 15 '12 at 20:50
  • Yes, you are right, after UAC change access denied error gone – JChan Aug 15 '12 at 20:53
  • yor solution not working on win7 64 bit professional system. I removed the UAC, I am always getting subkey count as 2. But my system has 10 sub keys. May specific to my system issue. I will accept your solution after finding this issue – JChan Aug 15 '12 at 21:12
  • @rkosgei, can you please update your solution with KEY_READ | KEY_WOW64_64KEY. It worked for me. so I can accept your solution – JChan Aug 15 '12 at 22:16
  • 2
    @rkosegi: Also this code dont count default Shell Icon Overlay Identifiers, etc. in Windows XP are 3: shortcut, sharing and slow file overlays. In Windows 95 (Who remember this? :-)) also was read only overlay too. – Xearinox Aug 16 '12 at 06:25
  • @Xearinox : +1, but OP asked how to get number of subkeys for specified registry key – rkosegi Aug 16 '12 at 06:47