Home > Software engineering >  C how to obtain all the icon in the control panel
C how to obtain all the icon in the control panel

Time:10-03

Such as topic, how to obtain the icon in the control panel

CodePudding user response:

http://www.cnblogs.com/likebeta/archive/2011/10/27/2226457.html
You consider this post,
Access the control panel icon, you is to get the icon resources?

CodePudding user response:

Should be called SHGetFileInfo API?

Research on MSDN

CodePudding user response:

It is difficult to do it! I watched WTL explorer program (use) of com technology, able to navigate to the directory panel, but ultimately not iterate over all the item, the resources or rarely online,

CodePudding user response:

% SystemRoot % \ system32 \ SHELL32 DLL
Pictures are in the inside,,

CodePudding user response:

The
reference 3 floor jacky_qiu response:
it is hard to do it! I watched WTL explorer program (use) of com technology, able to navigate to the directory panel, but ultimately not iterate through all the item, the resources or rarely online,
I found not enumerated projects, has been testing only enumerated to a Flash Player, just think of you the problem of 64, so the project into a 64 - bit, actually, is currently studying how to enumerate in 32-bit programs control panel of 64 project list,


Code to be compiled for 64 - bit project:
 # include & lt; Stdio. H> 
# include & lt; stdlib.h>
# include & lt; Tchar. H>
# include & lt; Windows. H>
# include & lt; Objbase. H>
# include & lt; Shlwapi. H>
# pragma comment (lib, "shlwapi. Lib")
# include & lt; Shlobj. H>
# pragma comment (lib, "uuid. Lib")

Int main (int arg c, char * argv [])
{
CoInitialize (NULL);
IShellFolder * PSHF=NULL;
Retrieves the hr=SHGetDesktopFolder (& amp; PSHF);
If (hr==S_OK) {
ITEMIDLIST * pidl=NULL;
Hr=SHGetFolderLocation (NULL, CSIDL_CONTROLS, NULL, 0, & amp; Pidl);
If (hr==S_OK) {
IShellFolder * PCPFLDR=NULL;
Hr=PSHF - & gt; BindToObject (pidl, NULL, & amp; IID_IShellFolder, (void * *) & amp; PCPFLDR);
If (hr==S_OK) {
Penum IEnumIDList *=NULL;
Hr=PCPFLDR - & gt; EnumObjects (NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, & amp; Penum);
If (hr==S_OK) {
ULONG ulFetched=0;
ITEMIDLIST * pcpitem=NULL;
While (penum - & gt; The Next (1, & amp; Pcpitem, & amp; UlFetched)=={S_OK)
/*
STRRET STRRET={0};
TCHAR szBuff [MAX_PATH]={0};
PCPFLDR - & gt; GetDisplayNameOf (pcpitem SHGDN_NORMAL, & amp; StrRet);
StrRetToBuf (& amp; StrRet pcpitem, szBuff MAX_PATH);

SHFILEINFO shfi={0};
SHGetFileInfo (LPCTSTR pcpitem, 0, & amp; Shfi, sizeof (SHFILEINFO), SHGFI_PIDL | SHGFI_ICON);

_tprintf (_T (" display name: % s \ n ")
Handle _T (" icon: % s \ n ")
_T (" \ n "),
SzBuff,
Shfi. HIcon);
*/
SHFILEINFO shfi={0};
SHGetFileInfo (LPCTSTR pcpitem, 0, & amp; Shfi, sizeof (SHFILEINFO), SHGFI_PIDL | SHGFI_ICON | SHGFI_DISPLAYNAME);

_tprintf (_T (" display name: % s \ n ")
Handle _T (" icon: % s \ n ")
_T (" \ n "),
Shfi szDisplayName,
Shfi. HIcon);

CoTaskMemFree (pcpitem);
}
Penum - & gt; Release ();
}
PCPFLDR - & gt; Release ();
}
CoTaskMemFree (pidl);
}
PSHF - & gt; Release ();
}
CoUninitialize ();
return 0;
}
is now looking for 32-bit programs enumeration method to control the panel project information,

CodePudding user response:

Note that because I am using the C code, transformation, C + + from:
 hr=PSHF - & gt; LpVtbl - & gt; BindToObject (PSHF pidl, NULL, & amp; IID_IShellFolder, (void * *) & amp; PCTL); 
to:
 hr=PSHF - & gt; BindToObject (pidl, NULL, & amp; IID_IShellFolder, (void * *) & amp; PCPFLDR); 
wrong, right should be:
 hr=PSHF - & gt; BindToObject (pidl, NULL, IID_IShellFolder, (void * *) & amp; PCPFLDR); 

CodePudding user response:

@ SXJIAKE, I give it a try

CodePudding user response:

refer to 7th floor CButtonST response:
@ SXJIAKE, I'll try
I tried it on, a control panel item name, I the code above is not successful, with a comment out that part of the "GetDisplayNameOf" instead of,

CodePudding user response:

refer to the eighth floor SXJIAKE response:
Quote: refer to 7th floor CButtonST response:

@ SXJIAKE, I'll try
I tried it on, a control panel item name, I the code above is not successful, with a comment out that part of the "GetDisplayNameOf" instead of,


No, the enumeration to only two, get name is empty

CodePudding user response:

The code here:
 # include & lt; Stdio. H> 
# include & lt; stdlib.h>
# include & lt; Tchar. H>
# define WINVER 0 x0500
# define WIN32_LEAN_AND_MEAN
# include & lt; Windows. H>
# include & lt; Objbase. H>
# include & lt; Shlwapi. H>
# include & lt; Shlobj. H>
# include & lt; Shellapi. H>
# pragma comment (lib, "uuid. Lib")
# pragma comment (lib, "ole32. Lib")
# pragma comment (lib, "shell32. Lib")
# pragma comment (lib, "shlwapi. Lib")

Int _tmain (int arg c, TCHAR * argv [])
{
Retrieves the hr=CoInitialize (NULL);
If (hr==S_OK) {
IShellFolder * pshfRoot=NULL;
Hr=SHGetDesktopFolder (& amp; PshfRoot);
If (hr==S_OK) {
ITEMIDLIST * pidlFolder=NULL;
Hr=SHGetFolderLocation (NULL, CSIDL_CONTROLS, NULL, 0, & amp; PidlFolder);
If (hr==S_OK) {
IShellFolder * pshfFolder=NULL;
Hr=pshfRoot - & gt; BindToObject (pidlFolder, NULL, IID_IShellFolder, (void * *) & amp; PshfFolder);
If (hr==S_OK) {
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related