最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

windows - Using ExtractIconEx if the registry is telling me the index is -1? - Stack Overflow

programmeradmin1浏览0评论

I was trying to use ExtractIconEx and the registry was telling me the value for the icon was this: %SystemRoot%\System32\usercpl.dll,-1

So, I expanded it out and like a normal string it's "c:\windows\System32\usercpl.dll,-1"

So, I use ExtractIconEx like I have been, and it fails to extract an icon. It seems like the documentation is poor... There are of course, notes about -1 if the pointers to the big and small icon are NULL, then the return is the number of icons in the file... blah, blah, blah...

It keeps returning 1 and the handle I get back is NULL... I'm calling it ok. The code is good. I am always extracting one large icon from wherever when I call it with an index not -1.

The documentation never comes out and says how you extract an icon where you want -1, i.e. the icon with resource ID #1....

If you want the third icon, you pass 2, but if you want the icon whose resource ID is 3, you pass -3....

From Microsoft

If this value is a negative number and either phiconLarge or phiconSmall is not NULL, the function begins by extracting the icon whose resource identifier is equal to the absolute value of nIconIndex. For example, use -3 to extract the icon whose resource identifier is 3

I finally just gave up and said, ok, I'll use 0 if the icon index is -1 and besides, for the case I was looking at, there was only 1 icon in the file. But, of course, loading images for objects where it specifies the icon in the registry is not always going to be so fortunate to have only 1 icon...

Then I thought about it... Is it the case that if the index is -1, then the icon will always be the first icon in the file and 0 is ok to use? It seems that if the icons are ordered, then numerically 1 would be the first icon in the file and so -1 and 0 would be interchangeable?

Of course, you might have icon #1... it might start with #2, but then it wouldn't be the edgecase of -1 and to get icon #2, I could just use -2 as the argument to the API...

I spent too much time on that...

发布评论

评论列表(0)

  1. 暂无评论