Recent

Author Topic: Gaining Associated Icons for EXE and Documents into a TimageList  (Read 642 times)

zxandris

  • Jr. Member
  • **
  • Posts: 92
I've got a simple launcher, and it displays items to launch in a popup.  Now currently I'm using pre-programmed icons for various file types but obviously it would be much better to have the actual system icons for both documents and applications.

Now I would love to post where I am on this but I honestly have no idea how to do it.  There used to be a delphi component that you'd supply it a file name and it was essentially an image list, and it'd return the icon.  Does anyone know how to hook into shelliconcache to do this, or some otherway of potentially building a TImageList to then offer the actual icons for associated files?

I would really appreciate help on this, I really don't know how to go about this but obviously it would be the best option.

Any help would be most appreciated,

Thanks

CJ

TRon

  • Hero Member
  • *****
  • Posts: 2506
Re: Gaining Associated Icons for EXE and Documents into a TimageList
« Reply #1 on: March 04, 2024, 02:50:29 am »
If windows only then you could take a look at windows shellapi function ExtractAssociatedIcon. It does not tell the complete story but that is where you could start.

zxandris

  • Jr. Member
  • **
  • Posts: 92
Re: Gaining Associated Icons for EXE and Documents into a TimageList
« Reply #2 on: March 08, 2024, 02:30:23 am »
Would it be aweful to admit I have zero idea how to go about making that into lazarus code...

I think it's what I want and I kinda assume I can use the icon i get to generate a image list, but I was hoping there was a nice lazarus answer to this.  I think the file controls, treeview and tlistview can do this, but I would have zero idea how to go about finding that.  I'm pretty much still a novice despite how long I've been programming.

Any help would be wonderful,

CJ

TRon

  • Hero Member
  • *****
  • Posts: 2506
Re: Gaining Associated Icons for EXE and Documents into a TimageList
« Reply #3 on: March 08, 2024, 03:48:28 am »
I think it's what I want and I kinda assume I can use the icon i get to generate a image list,
Exactly that, so you do seem to know :)

Quote
but I was hoping there was a nice lazarus answer to this.
I don't believe there is a such a component that is able to do that for you (but perhaps someone else knows of one ?).

Quote
Any help would be wonderful,
I would love to help but I don't have/use Windows anymore (for ages now) so that would end up nowhere for me ...  :(

bobby100

  • Full Member
  • ***
  • Posts: 164
    • Malzilla
Re: Gaining Associated Icons for EXE and Documents into a TimageList
« Reply #4 on: March 08, 2024, 06:27:10 am »
KIcon from KControls package (available in Online Package Manager) can load icon files from executables etc. There is also a demo project in the package.

System icons are in \WINDOWS\system32\shell32.dll

One file can contain multiple icons. At reading icons from a file, you can specify the icon index to get icons other than the first one. You need to do error handling here, because not every index must contain an icon.
https://gitlab.com/bobby100 - my Lazarus components and units
https://sourceforge.net/u/boban_spasic/profile/ - my open source apps

https://malzilla.org/ - remainder at my previous life as a web security expert

 

TinyPortal © 2005-2018