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
Interesting article about...
by
LV
[
Today
at 05:51:47 am]
how to control the order ...
by
TRon
[
Today
at 05:00:02 am]
D2Bridge Framework for La...
by
egsuh
[
Today
at 04:48:02 am]
Application deployment
by
cousinp
[
Today
at 04:28:36 am]
[SOLVED] FPSpreadSheet, ...
by
TRon
[
Today
at 01:25:51 am]
Is it possible to do git ...
by
TRon
[
Today
at 12:41:39 am]
had a question and found ...
by
TRon
[
Today
at 12:36:57 am]
Draw Transparent Fill Rec...
by
LBox
[
Today
at 12:00:51 am]
Wiki, a dead link in page...
by
d7_2_laz
[December 09, 2024, 10:53:21 pm]
MIDI commands
by
TRon
[December 09, 2024, 10:43:22 pm]
Record "inheritance"/stru...
by
PascalDragon
[December 09, 2024, 10:31:25 pm]
Who catches the Linux sig...
by
LV
[December 09, 2024, 09:47:15 pm]
FreePascal version of gcc...
by
PascalDragon
[December 09, 2024, 09:45:02 pm]
Lazarus for Windows on aa...
by
PascalDragon
[December 09, 2024, 09:21:38 pm]
SAVE StringGrid to PDF
by
dseligo
[December 09, 2024, 07:42:30 pm]
ColorDialog can have opti...
by
Bart
[December 09, 2024, 06:07:24 pm]
Hustle - A simple task ma...
by
BSaidus
[December 09, 2024, 04:58:15 pm]
Notepad++ plugin with doc...
by
d7_2_laz
[December 09, 2024, 04:07:14 pm]
TLazSerial : serial port ...
by
CM630
[December 09, 2024, 04:05:20 pm]
MainMenu: How to use the ...
by
madref
[December 09, 2024, 03:39:05 pm]
Program running on after ...
by
MarkMLl
[December 09, 2024, 03:23:45 pm]
Array of String lookup gi...
by
jcmontherock
[December 09, 2024, 11:50:47 am]
The Silver Coder on YouTu...
by
silvercoder70
[December 09, 2024, 11:49:09 am]
Api/component pack for Ra...
by
cdbc
[December 09, 2024, 11:43:17 am]
How to know when dragging...
by
Aistis
[December 09, 2024, 10:41:22 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [Solved]How to programmatically determine if an external .exe has embedded icons (Read 2860 times)
Ten_Mile_Hike
Jr. Member
Posts: 87
[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: 612
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: 6585
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: 612
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: 6585
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: 87
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