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
Why with allows assignmen...
by
egsuh
[
Today
at 06:46:30 am]
file Blockread error
by
TBMan
[
Today
at 03:45:29 am]
[SOLVED]Might have a menu...
by
Tony Stone
[
Today
at 03:30:15 am]
Lazarus Release 3.6
by
dbannon
[
Today
at 03:25:19 am]
Nested declarations insid...
by
440bx
[
Today
at 02:24:16 am]
how to create sync applic...
by
ASerge
[
Today
at 01:40:33 am]
test if web site is valid
by
Warfley
[
Today
at 01:22:48 am]
File operations blocking ...
by
TRon
[
Today
at 01:15:30 am]
[Solved] TPopupMenu OnDra...
by
d7_2_laz
[
Today
at 12:37:26 am]
how to make application r...
by
DragoRosso
[
Today
at 12:19:23 am]
Discussion: How do you di...
by
dbannon
[
Today
at 12:18:30 am]
Assigning proc to event a...
by
Bart
[January 13, 2025, 10:16:59 pm]
SDL2 image rotation Probl...
by
TRon
[January 13, 2025, 10:00:09 pm]
Color Buttons
by
lainz
[January 13, 2025, 09:14:49 pm]
Lazarus Pascal Keywords a...
by
PascalDragon
[January 13, 2025, 09:11:42 pm]
Generics as PUBLISHED imp...
by
PascalDragon
[January 13, 2025, 09:04:43 pm]
FP crashes after running ...
by
Martin_fr
[January 13, 2025, 09:03:42 pm]
Random ?
by
Thaddy
[January 13, 2025, 07:26:20 pm]
UnoLib - library in Pasca...
by
ackarwow
[January 13, 2025, 07:08:06 pm]
¿Hay alguna limitación en...
by
e_nigma
[January 13, 2025, 06:27:03 pm]
Exploring FPC/Lazarus uni...
by
MarkMLl
[January 13, 2025, 05:48:05 pm]
Web Pascal without JavaSc...
by
zendrael
[January 13, 2025, 05:19:57 pm]
MainMenu: How to use the ...
by
madref
[January 13, 2025, 03:03:37 pm]
How to combine data from ...
by
Thaddy
[January 13, 2025, 02:30:11 pm]
SDL2: Runtime Error 216 o...
by
mischi
[January 13, 2025, 02:11:35 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [Solved]How to programmatically determine if an external .exe has embedded icons (Read 2918 times)
Ten_Mile_Hike
Jr. Member
Posts: 89
[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: 6639
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: 6639
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: 89
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