How to find out the number of icons on the desktop, if I recognized the pointer to the window containing icons like this:

var HDesktop :HWND; //... HDesktop := FindWindow('ProgMan', nil); HDesktop := GetWindow(HDesktop, GW_CHILD); HDesktop := GetWindow(HDesktop, GW_CHILD); 
  • For reference: kosher IActiveDesktop in whist + does not support counting elements. - karmadro4

1 answer 1

Thus, you found a window with the SysListView32 class. Now you just need to send him a message LVM_GETITEMCOUNT or call

 ItemCount := ListView_GetItemCount(HDesktop); 

which sends this message and ...

Threat uses CommCtrl;

  • The hack is that the private members are touched by the method :-) However, I consider this hack a better solution than the zoo of rapidly changing interfaces (see my comment about the resignation of IActiveDesktop) - karmadro4
  • I do not see any hack in sending a message to the window. All CommCtrl in these hacks and half of vcl too. Windows handles are not private, but very public. IActiveDesktop - [this?] [1] Legacy Shell Features. This feature is only supported under Windows XP or earlier. TS asked about ProgMan ... [1]: msdn.microsoft.com/en-us/library/bb776830(v=vs.85).aspx - Yura Ivanov
  • You say so, as if PROGMAN is not a legacy :-) The message is not a hack, finding SysListView32 is a hack. - karmadro4
  • ProgMan is compatibility, not legacy. "C: \ Program Files \ Borland \ Delphi7 \ Bin \ WS32.EXE" - hacking utility? But I see no reason to argue. - Yura Ivanov