Problems with IExtractIcon::Extract

Chris Sutcliffe <[email protected]> Thu, 5 Jan 2006 11:19:25 -0500
Newsgroups gmane.comp.windows.shell-shocked.devel
Message-ID <[email protected]>
------=_Part_701_9135783.1136477965147
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hey All,

I've written some code to extract the icons from files:

   if (SUCCEEDED(SHGetDesktopFolder(&deskFolder)))
   {
       if (SUCCEEDED(deskFolder->ParseDisplayName(NULL, NULL, file,
NULL, &pidlLocal, NULL)))
       {
           pidlTmp =3D ILFindLastID(pidlLocal);

           pidlRelative =3D ILClone(pidlTmp);
           ILRemoveLastID(pidlLocal);

           if (SUCCEEDED(deskFolder->BindToObject(pidlLocal, NULL,
IID_IShellFolder, (void**)&appObject)))
           {
               ILFree(pidlLocal);

               if (SUCCEEDED(appObject->GetUIObjectOf(NULL, 1,
(LPCITEMIDLIST*)&pidlRelative,
                   IID_IExtractIcon, NULL, (void**)&extractIcon)))
               {
                   ILFree(pidlRelative);
                   if
(SUCCEEDED(extractIcon->GetIconLocation(GIL_FORSHELL, iconLocation,
MAX_PATH, &iconIndex,
                       &iconFlags)))
                   {
                       if (iconSize =3D=3D 16)
                           extractIcon->Extract(iconLocation,
iconIndex, NULL, &icon, MAKELONG(16, 16));
                       else if (iconSize =3D=3D 48)
                           extractIcon->Extract(iconLocation,
iconIndex, &icon, NULL, MAKELONG(48, 16));
                       else
                           extractIcon->Extract(iconLocation,
iconIndex, &icon, NULL, MAKELONG(32, 16));

                       extractIcon->Release();
                   }
               }

               appObject->Release();
           }
       }

       deskFolder->Release();
   }

This works well most of the time (including the handling of regular
shortcuts).  The problem I have is that when I attempt the Extact on an
Internet Shortcut, it ends up crashing, despite the fact that iconLocation
and iconIndex are valid.  Does anybody have any
ideas?

Thanx!

Chris

--
Chris Sutcliffe
http://emergedesktop.org

------=_Part_701_9135783.1136477965147
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hey All,<br><br>I've written some code to extract the icons from files:<br>=
<br> &nbsp; &nbsp;if (SUCCEEDED(SHGetDesktopFolder(<div id=3D"mb_0">&amp;de=
skFolder)))<br> &nbsp; &nbsp;{<br> &nbsp; &nbsp; &nbsp; &nbsp;if (SUCCEEDED=
(deskFolder-&gt;ParseDisplayName(NULL, NULL, file,
<br>NULL, &amp;pidlLocal, NULL)))<br> &nbsp; &nbsp; &nbsp; &nbsp;{<br> &nbs=
p; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pidlTmp =3D ILFindLastID(pidlLocal);<b=
r><br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pidlRelative =3D ILClone(pi=
dlTmp);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ILRemoveLastID(pidlLoc=
al);<br><br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (SUCCEEDED(deskFol=
der-&gt;BindToObject(pidlLocal, NULL,
<br>IID_IShellFolder, (void**)&amp;appObject)))<br> &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp;{<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp;ILFree(pidlLocal);<br><br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp;if (SUCCEEDED(appObject-&gt;GetUIObjectOf(NULL, 1,<br>(LPCITEMID=
LIST*)&amp;pidlRelative,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp; &nbsp; &nbsp;IID_IExtractIcon, NULL, (void**)&amp;extractIcon)))
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br> &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ILFree(pidlRela=
tive);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp;if<br>(SUCCEEDED(extractIcon-&gt;GetIconLocation(GIL_FORSHELL, iconLoc=
ation,<br>MAX_PATH, &amp;iconIndex,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&amp;iconFlags)))
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{=
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp;if (iconSize =3D=3D 16)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;extractIcon-=
&gt;Extract(iconLocation,<br>iconIndex, NULL, &amp;icon, MAKELONG(16, 16));=
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp;else if (iconSize =3D=3D 48)
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp;extractIcon-&gt;Extract(iconLocation,<br>iconInd=
ex, &amp;icon, NULL, MAKELONG(48, 16));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br> &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp;extractIcon-&gt;Extract(iconLocation,<br>
iconIndex, &amp;icon, NULL, MAKELONG(32, 16));<br><br> &nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;extractIcon-=
&gt;Release();<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp;}<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}=
<br><br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;appObject-&=
gt;Release();<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br> &nbsp; &nb=
sp; &nbsp; &nbsp;}
<br><br> &nbsp; &nbsp; &nbsp; &nbsp;deskFolder-&gt;Release();<br> &nbsp; &n=
bsp;}<br><br>This works well most of the time (including the handling of re=
gular shortcuts). &nbsp;The problem I have is that when I attempt the Extac=
t on an Internet Shortcut, it ends up crashing, despite the fact that iconL=
ocation and iconIndex are valid. &nbsp;Does anybody have any
<br>ideas?<br><br>Thanx!<br><span class=3D"sg"><br>Chris</span></div><br>--=
 <br>Chris Sutcliffe<br><a href=3D"http://emergedesktop.org" target=3D"_bla=
nk" onclick=3D"return top.js.OpenExtLink(window,event,this)">http://emerged=
esktop.org
</a>


------=_Part_701_9135783.1136477965147--

__________________________________________________
Subscription options and archive:
http://www.freelists.org/list/shell-coding