News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Geting Icon index or handle from file extention!

Started by xandaz, May 30, 2012, 08:53:46 AM

Previous topic - Next topic

xandaz

    i'm making a rar extractor and while the content of the file is still compacted i need to extract either the index or handle of the icon that corresponds to the extention. I'm not aware of any function that could do so. I tried ExtracAssociatedIconEx and ExtractIcon with 0 for module Instance but didn't work. Can it be done via registry. Does anybody have any idea? Thanks in advance.
    Laters
    X

Gunner

Stay OUT of the Registry.  Use SHGetFileInfo

Something like this should work:
    invoke  SHGetFileInfo, offset szExtension, NULL, offset sfi, sizeof SHFILEINFO, SHGFI_SYSICONINDEX or SHGFI_USEFILEATTRIBUTES or SHGFI_ICON or SHGFI_SMALLICON
    invoke  ImageList_AddIcon, himlTabs, sfi.hIcon
    invoke  DestroyIcon, sfi.hIcon

this will fill in the icon index in the system imagelist sfi.iIcon and the handle of the icon sfi.hIcon
~Rob

xandaz

   yea? but does it work with just the extention? what's the format?
*.rar

...cause i tried that and didnt work.
   thanks gunner i appreciate the help. I'm waittin.
   soon

xandaz

  oh yeah gunner. after reading the sdk i understood. thanks gunna.
  later and regards
  x

xandaz

   Couldn't get it to work... does anyone know what's the extention fomat? Is it '*.ext',0 or what?

dedndave

try passing a "fictional" filename. like 'x.rar',0

also - set the SHFILEINFO dwAttributes member to FILE_ATTRIBUTE_NORMAL before the call

xandaz

    thanks dave. will do so... i'll let you know how it went.

xandaz

   Not working.... even tried FILE_ATTR_COMPRESSED and both and none.

dedndave


xandaz

   wait....it works.... it was an listview problem.... forgot to xor imask,LVIF_IMAGE+PARAM that's all. Sorry.... i always miss something stupid. Thanks dave and gunner

dedndave

yah - my mistake, too
you set the file attribute in the parm - not in the struct...
        INVOKE  SHGetFileInfo,offset szExtension,FILE_ATTRIBUTE_NORMAL,offset shfi,sizeof SHFILEINFO,
                SHGFI_SYSICONINDEX or SHGFI_USEFILEATTRIBUTES or SHGFI_ICON or SHGFI_SMALLICON


also - it appears that '.rar',0 will work for an extension format

xandaz

    oks.... althought i read here...http://blogs.msdn.com/b/oldnewthing/archive/2004/06/01/145428.aspx
    thx dave. i appreciate it.... i'm coming close to about 2000 lines of code devided be several source files. I feel tired. I'll prolly drop once i get bored as i do with everything else....lol. bb

dedndave


xandaz