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
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
TImage colors incorrect
by
Jonny
[
Today
at 12:39:25 am]
Nested declarations insid...
by
Warfley
[
Today
at 12:27:44 am]
MQTT Client
by
dbannon
[
Today
at 12:07:40 am]
Programs writing programs...
by
Curt Carpenter
[
Today
at 12:06:18 am]
Using Masurement Computin...
by
Sander
[January 17, 2025, 11:33:30 pm]
A Tip for beginners
by
Ten_Mile_Hike
[January 17, 2025, 11:10:10 pm]
FPC 3.2.4, naming suggest...
by
JuhaManninen
[January 17, 2025, 10:39:58 pm]
Lazarus Release Candidate...
by
verasan
[January 17, 2025, 10:25:58 pm]
VGM Player
by
Gigatron2
[January 17, 2025, 09:29:09 pm]
Artificial intelligence
by
Fred vS
[January 17, 2025, 07:57:53 pm]
How to avoid copying
by
Amir61
[January 17, 2025, 07:55:16 pm]
UnoLib - library in Pasca...
by
ackarwow
[January 17, 2025, 07:25:40 pm]
Bug in the formula MATCH
by
wp
[January 17, 2025, 06:38:31 pm]
Restoring minimized scree...
by
Thaddy
[January 17, 2025, 06:31:25 pm]
Problem in writing formul...
by
wp
[January 17, 2025, 06:16:53 pm]
Preparing FPC 3.2.4, poin...
by
lainz
[January 17, 2025, 02:29:45 pm]
LCL Web Native with D2Bri...
by
BlueIcaro
[January 17, 2025, 01:06:25 pm]
Connection issues, contin...
by
Zvoni
[January 17, 2025, 12:48:24 pm]
Order of dialog buttons?
by
dsiders
[January 17, 2025, 11:16:21 am]
Where do I get IdHTTP, ...
by
Remy Lebeau
[January 17, 2025, 10:35:12 am]
Output directory for exe
by
d2010
[January 17, 2025, 10:22:51 am]
Debugging a new package?
by
Martin_fr
[January 17, 2025, 10:13:05 am]
Making sense of pparser, ...
by
JernejL
[January 17, 2025, 09:46:54 am]
CPU-View
by
Alexander (Rouse_) Bagel
[January 17, 2025, 09:36:12 am]
TIdSMTP problems
by
Remy Lebeau
[January 17, 2025, 09:30:03 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [Solved]How to programmatically determine if an external .exe has embedded icons (Read 2922 times)
Ten_Mile_Hike
Jr. Member
Posts: 90
[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
When any government, or any church for that matter, undertakes to say to its subjects, This you may not read, this you
must not see, this you are forbidden to know, the end result is tyranny and oppression no matter how holy the motives.
Robert A. Heinlein
Fibonacci
Hero Member
Posts: 643
Internal Error Hunter
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: 6641
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
Hero Member
Posts: 643
Internal Error Hunter
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: 6641
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
Jr. Member
Posts: 90
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
When any government, or any church for that matter, undertakes to say to its subjects, This you may not read, this you
must not see, this you are forbidden to know, the end result is tyranny and oppression no matter how holy the motives.
Robert A. Heinlein
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