分享
 
 
 

得到windows系统图标的解决方案

王朝vc·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

如果想得到windows中我的电脑或者网络邻居等系统图标可以有如下解决办法。

方案一

用图标提取软件从c:\winnt\system32\SHELL32.dll或者C:\WINNT\Explorer.exe中提取出来然后加入到自己的程序中(路径随操作系统和安装目录不同而变化)这种方法的缺点是不同的操作系统的系统图标有一些变化,比如说2003和2000的系统图标就有很大变化,如果你提取的是2000的图标,应用程序如果在2003下运行可能看起来有一些别扭。

方案二

同样是利用c:\winnt\system32\SHELL32文件来提取,但是这次是利用注册表和windows的函数来完成。代码如下:

HICON CTestDlg::GetShellIcon(int nIndex)

{

HICON hIcon=NULL;

HKEY hkeyShellIcons;

//打开注册表,读相应的图标项目

if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell I cons", 0,KEY_READ,&hkeyShellIcons)==ERROR_SUCCESS)

{

char szBuffer[MAX_PATH];

DWORD dwSize=MAX_PATH;

char szIndex[4];

sprintf(szIndex,"%d",nIndex);

if(RegQueryValueEx(hkeyShellIcons,szIndex,NULL,NULL,(LPBYTE)szBuffer,&dwSize)==ERROR_SUCCESS)

{

CString strFile,strIndex;

AfxExtractSubString(strFile,szBuffer,0,',');

AfxExtractSubString(strIndex,szBuffer,1,',');

ExtractIconEx(strFile,atoi(strIndex),NULL,&hIcon,1);

}

RegCloseKey(hkeyShellIcons);

}

if(!hIcon)

ExtractIconEx("SHELL32.DLL",nIndex,NULL,&hIcon,1);

return hIcon;

}

这种方法克服了第一种方法使用不灵活的缺点但是代码量比较大。(index目录在最后列出)

方案三

利用shell函数SHGetSpecialFolderLocation和SHGetFileInfo。代码如下:

LPITEMIDLIST lpItemIDList;

SHFILEINFO shinfo;

SHGetSpecialFolderLocation (this->m_hWnd, CSIDL_NETWORK, &lpItemIDList);

SHGetFileInfo( (LPCTSTR)lpItemIDList,

NULL,

&shinfo,

sizeof(shinfo),

SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME | SHGFI_ICON| SHGFI_SMALLICON|SHGFI_PIDL);

这是shinfo中的icon和hicon保存了得到的icon的值。

这种方法既有灵活性,代码量也比较少,推荐使用。在SHGetSpecialFolderLocation中的第二个参数是想得到的图片的CSIDL值。

【附表1:nindex值说明】

nIndex 意义 说明

0 默认图标

1 默认的 .doc 图标*

2 可执行文件图标

3 关闭的文件夹图标

4 打开的文件夹图标

5 5.25' 驱动器图标

6 3.5' 驱动器图标

7 可移动的驱动器图标

8 硬盘驱动器图标

9 网络驱动器图标

10 断开的网络驱动器图标

11 CD-ROM驱动器图标

12 RAM驱动器图标

13 整个网络图标

14 网络连接图标 u

15 网络工作站图标

16 本地打印机图标 *

17 网络图标 u

18 网络工作组图标 u

19 程序组图标 s

20 文档图标 s

21 设置图标 s

22 查找图标 s

23 帮助图标 s

24 运行图标 s

25 睡眠图标 s

26 Docking Station 图标 u

27 关机图标 s

28 共享图标 t

29 快捷方式的箭头图标 t

30 大箭头图标 u

31 空回收站图标 *

32 满的回收站图标 *

33 拨号网络图标 *

34 桌面图标

35 控制台图标 *

36 程序组图标 s

37 打印机文件夹图标 *

38 字体文件夹图标 *

39 Windows旗帜图标 *

40 Audio CD 图标

.

.

.

.49

后面标有符号的说明有特殊用法:

* 这些图标可以在注册表的其他地方的设置。

t 这些图标必须是空白背景。

s 这些图标将用在开始菜单上。

u 这些图标可能并没有使用或不能通过注册表修改

【附表2:CSIDL Values】

A number of folders are used frequently by applications, but may not have the same name or location on any given system. For example, the system folder may be "C:\Windows" on one system and "C:\Winnt" on another. CSIDL values provide a unique system-independent way to identify these special folders. The values supersede the use of environment variables for this purpose.

A CSIDL is used in conjunction with one of four Shell functions, SHGetFolderLocation, SHGetFolderPath, SHGetSpecialFolderLocation, and SHGetSpecialFolderPath, to retrieve a special folder's pathname or item ID list (PIDL).

If a special folder does not exist, you can force its creation by using the following special CSIDL:

CSIDL_FLAG_CREATE

Version 5.0. Combine this CSIDL with any of the CSIDLs listed below to force the creation of the associated folder.

The remaining CSIDLs correspond to either file system folders or virtual folders. Where the CSIDL identifies a file system folder, a commonly used path is given as an example. Other paths may be used. Some CSIDLs can be mapped to an equivalent %VariableName% environment variable. CSIDLs are more reliable, however, and should be used if possible.

CSIDL_ADMINTOOLS

Version 5.0. File system directory that is used to store administrative tools for an individual user. The Microsoft Management Console will save customized consoles to this directory, and it will roam with the user.

CSIDL_ALTSTARTUP

File system directory that corresponds to the user's nonlocalized Startup program group.

CSIDL_APPDATA

Version 4.71. File system directory that serves as a common repository for application-specific data. A typical path is C:\Documents and Settings\username\Application Data. This CSIDL is supported by the redistributable ShFolder.dll for systems that do not have the Internet Explorer 4.0 integrated Shell installed.

CSIDL_BITBUCKET

Virtual folder containing the objects in the user's Recycle Bin.

CSIDL_COMMON_ADMINTOOLS

Version 5.0. File system directory containing containing administrative tools for all users of the computer.

CSIDL_COMMON_ALTSTARTUP

File system directory that corresponds to the nonlocalized Startup program group for all users. Valid only for Windows NT® systems.

CSIDL_COMMON_APPDATA

Version 5.0. Application data for all users. A typical path is C:\Documents and Settings\All Users\Application Data.

CSIDL_COMMON_DESKTOPDIRECTORY

File system directory that contains files and folders that appear on the desktop for all users. A typical path is C:\Documents and Settings\All Users\Desktop. Valid only for Windows NT® systems.

CSIDL_COMMON_DOCUMENTS

File system directory that contains documents that are common to all users. Typical paths are C:\Documents and Settings\All Users\Documents. Valid for Windows NT® systems and Windows 95 and Windows 98 systems with Shfolder.dll installed.

CSIDL_COMMON_FAVORITES

File system directory that serves as a common repository for all users' favorite items. Valid only for Windows NT® systems.

CSIDL_COMMON_PROGRAMS

File system directory that contains the directories for the common program groups that appear on the Start menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs. Valid only for Windows NT® systems.

CSIDL_COMMON_STARTMENU

File system directory that contains the programs and folders that appear on the Start menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu. Valid only for Windows NT® systems.

CSIDL_COMMON_STARTUP

File system directory that contains the programs that appear in the Startup folder for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs\Startup. Valid only for Windows NT® systems.

CSIDL_COMMON_TEMPLATES

File system directory that contains the templates that are available to all users. A typical path is C:\Documents and Settings\All Users\Templates. Valid only for Windows NT® systems.

CSIDL_CONTROLS

Virtual folder containing icons for the Control Panel applications.

CSIDL_COOKIES

File system directory that serves as a common repository for Internet cookies. A typical path is C:\Documents and Settings\username\Cookies.

CSIDL_DESKTOP

Windows Desktop—virtual folder that is the root of the namespace.

CSIDL_DESKTOPDIRECTORY

File system directory used to physically store file objects on the desktop (not to be confused with the desktop folder itself). A typical path is C:\Documents and Settings\username\Desktop

CSIDL_DRIVES

My Computer—virtual folder containing everything on the local computer: storage devices, printers, and Control Panel. The folder may also contain mapped network drives.

CSIDL_FAVORITES

File system directory that serves as a common repository for the user's favorite items. A typical path is C:\Documents and Settings\username\Favorites.

CSIDL_FONTS

Virtual folder containing fonts. A typical path is C:\WINNT\Fonts.

CSIDL_HISTORY

File system directory that serves as a common repository for Internet history items.

CSIDL_INTERNET

Virtual folder representing the Internet.

CSIDL_INTERNET_CACHE

Version 4.72. File system directory that serves as a common repository for temporary Internet files. A typical path is C:\Documents and Settings\username\Temporary Internet Files.

CSIDL_LOCAL_APPDATA

Version 5.0. File system directory that serves as a data repository for local (nonroaming) applications. A typical path is C:\Documents and Settings\username\Local Settings\Application Data.

CSIDL_MYMUSIC

File system directory that serves as a common repository for music files. A typical path is C:\My Music.

CSIDL_MYPICTURES

Version 5.0. My Pictures folder. A typical path is C:\Documents and Settings\username\My Documents\My Pictures.

CSIDL_NETHOOD

A file system folder containing the link objects that may exist in the My Network Places virtual folder. It is not the same as CSIDL_NETWORK, which represents the network namespace root. A typical path is C:\Documents and Settings\username\NetHood.

CSIDL_NETWORK

Network Neighborhood—virtual folder representing the root of the network namespace hierarchy.

CSIDL_PERSONAL

File system directory that serves as a common repository for documents. A typical path is C:\Documents and Settings\username\My Documents. This should be distinguished from the virtual My Documents folder in the namespace. To access that virtual folder, use the technique described in Managing the File System.

CSIDL_PRINTERS

Virtual folder containing installed printers.

CSIDL_PRINTHOOD

File system directory that contains the link objects that may exist in the Printers virtual folder. A typical path is C:\Documents and Settings\username\PrintHood.

CSIDL_PROFILE

Version 5.0. User's profile folder.

CSIDL_PROGRAM_FILES

Version 5.0. Program Files folder. A typical path is C:\Program Files.

CSIDL_PROGRAM_FILES_COMMON

Version 5.0. A folder for components that are shared across applications. A typical path is C:\Program Files\Common. Valid only for Windows NT® and Windows® 2000 systems.

CSIDL_PROGRAMS

File system directory that contains the user's program groups (which are also file system directories). A typical path is C:\Documents and Settings\username\Start Menu\Programs.

CSIDL_RECENT

File system directory that contains the user's most recently used documents. A typical path is C:\Documents and Settings\username\Recent. To create a shortcut in this folder, use SHAddToRecentDocs. In addition to creating the shortcut, this function updates the Shell's list of recent documents and adds the shortcut to the Documents submenu of the Start menu.

CSIDL_SENDTO

File system directory that contains Send To menu items. A typical path is C:\Documents and Settings\username\SendTo.

CSIDL_STARTMENU

File system directory containing Start menu items. A typical path is C:\Documents and Settings\username\Start Menu.

CSIDL_STARTUP

File system directory that corresponds to the user's Startup program group. The system starts these programs whenever any user logs onto Windows NT® or starts Windows® 95. A typical path is C:\Documents and Settings\username\Start Menu\Programs\Startup.

CSIDL_SYSTEM

Version 5.0. System folder. A typical path is C:\WINNT\SYSTEM32.

CSIDL_TEMPLATES

File system directory that serves as a common repository for document templates.

CSIDL_WINDOWS

Version 5.0. Windows directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT% environment variables. A typical path is C:\WINNT.

author:simahao 2005.1.3

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有