Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
Windows
(Moderators:
FPK
,
Tomas Hajny
) »
[Solved]How to programmatically determine if an external .exe has embedded icons
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Lazarus 3.0 on linux
by
Codrut1001
[
Today
at 07:03:07 pm]
BGRA Controls Install Lat...
by
andrew Bubble
[
Today
at 06:56:53 pm]
how to change color of a ...
by
Sino7524
[
Today
at 06:10:49 pm]
What is the meaning of TF...
by
Hartmut
[
Today
at 05:35:18 pm]
ImGui FreePascal Binding ...
by
Coldzer0
[
Today
at 05:28:50 pm]
Can't build a project gro...
by
MarkMLl
[
Today
at 05:22:14 pm]
TFileStream.ReadAnsiStrin...
by
simone
[
Today
at 05:16:57 pm]
Why cannot this be inline...
by
Stefan Glienke
[
Today
at 05:05:12 pm]
TPath enhancements (Issue...
by
VisualLab
[
Today
at 04:47:46 pm]
Sleep forever
by
jollytall
[
Today
at 03:56:12 pm]
jwabcrypt unit is missing
by
fpc_2024
[
Today
at 03:08:24 pm]
Problems with accentuatio...
by
Gercino
[
Today
at 02:47:54 pm]
Lazarus Install PI5 Bookw...
by
paweld
[
Today
at 01:36:00 pm]
Conscious Artificial Inte...
by
Dzandaa
[
Today
at 01:07:14 pm]
BGRABitmap - showcase -
by
Mongkey
[
Today
at 11:14:36 am]
Patt - a small ball bounc...
by
thehay95
[
Today
at 11:06:17 am]
Windows API and wide/unic...
by
marcov
[
Today
at 10:49:07 am]
Huge problem with open fi...
by
dseligo
[
Today
at 10:09:29 am]
[SOLVED] TPanel slider po...
by
Thaddy
[
Today
at 09:21:09 am]
Lazarus corrupted my enti...
by
Martin_fr
[
Today
at 08:50:09 am]
GUI for ChatGPT (yarvis)
by
Thaddy
[
Today
at 07:46:19 am]
Lazarus IDE Windows "stuc...
by
Tony Stone
[
Today
at 01:47:54 am]
[SOLVED] Does using TTime...
by
EganSolo
[November 28, 2023, 11:38:26 pm]
Anyone interested in test...
by
PascalDragon
[November 28, 2023, 09:23:21 pm]
[SOLVED]Diferences in Gen...
by
janasoft
[November 28, 2023, 09:05:14 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [Solved]How to programmatically determine if an external .exe has embedded icons (Read 952 times)
Ten_Mile_Hike
New Member
Posts: 30
[Solved]How to programmatically determine if an external .exe has embedded icons
«
on:
August 29, 2023, 06:50:36 pm »
Hi,
Simplest code to determine presence of embedded icon. NO NEED TO EXTRACT, just looking for presence
Thank You
«
Last Edit: August 29, 2023, 11:25:55 pm by Ten_Mile_Hike
»
Logged
Fibonacci
Full Member
Posts: 219
#PDK
Re: How to programmatically determine if an external .exe has embedded icons
«
Reply #1 on:
August 29, 2023, 07:02:52 pm »
You are in luck, I happen to have such code
Code: Pascal
[Select]
[+]
[-]
uses
Windows
;
function
resenumtypes
(
hModule
:
HMODULE
;
lpType
:
LPSTR
;
lParam
:
LONG_PTR
)
:
BOOL
;
stdcall
;
begin
result
:
=
true
;
if
lpType
=
RT_ICON
then
begin
PBoolean32
(
lParam
)
^
:
=
true
;
result
:
=
false
;
//stop enumerating
end
;
end
;
var
h
:
hwnd
;
has_icon
:
boolean
=
false
;
begin
h
:
=
LoadLibraryEx
(
'C:\Windows\explorer.exe'
,
0
,
LOAD_LIBRARY_AS_IMAGE_RESOURCE
+
LOAD_LIBRARY_AS_DATAFILE
)
;
if
h >
0
then
begin
EnumResourceTypes
(
h
,
@
resenumtypes
,
LONG_PTR
(
@
has_icon
)
)
;
writeln
(
'has icon? '
,
has_icon
)
;
end
else
begin
writeln
(
'cant open file'
)
;
end
;
readln
;
end
.
Logged
rvk
Hero Member
Posts: 5648
Re: How to programmatically determine if an external .exe has embedded icons
«
Reply #2 on:
August 29, 2023, 07:10:30 pm »
Quote from: Fibonacci on August 29, 2023, 07:02:52 pm
You are in luck, I happen to have such code
I'm not sure if ANY icon is what is asked for or the actual program icon.
Your code looks for ANY icon (of I'm not mistaken)?
You can use ExtractIconEx for the actual program icon.
https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-extracticonexa
You can probably use the ExtractIcon function for this.
Logged
Fibonacci
Full Member
Posts: 219
#PDK
Re: How to programmatically determine if an external .exe has embedded icons
«
Reply #3 on:
August 29, 2023, 07:13:45 pm »
He didn't specify it has to be MAINICON
Logged
rvk
Hero Member
Posts: 5648
Re: How to programmatically determine if an external .exe has embedded icons
«
Reply #4 on:
August 29, 2023, 07:21:53 pm »
Quote from: Fibonacci on August 29, 2023, 07:13:45 pm
He didn't specify it has to be MAINICON
No (s)he didn't but seeing that only the presence is requested it would make sense it would be the MAINICON.
Anyway, now both methods are documented in this topic
Logged
Ten_Mile_Hike
New Member
Posts: 30
Re: How to programmatically determine if an external .exe has embedded icons
«
Reply #5 on:
August 29, 2023, 11:28:08 pm »
Thank You
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
Windows
(Moderators:
FPK
,
Tomas Hajny
) »
[Solved]How to programmatically determine if an external .exe has embedded icons
TinyPortal
© 2005-2018