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
440bx
[
Today
at 02:55:33 am]
uMain.pas(150,29) Error: ...
by
dseligo
[
Today
at 01:53:00 am]
TvsComPort on MacOS Sierr...
by
Jurassic Pork
[
Today
at 01:48:33 am]
Adding interfaces to any ...
by
ASerge
[
Today
at 01:40:33 am]
Starting a program with h...
by
jeremiah
[
Today
at 12:58:26 am]
Bug in string concatenati...
by
Fibonacci
[
Today
at 12:47:23 am]
fphttpclient https/tls on...
by
fireboxsoft
[
Today
at 12:38:12 am]
Q: Debug a plugin DLL: 'h...
by
Martin_fr
[
Today
at 12:32:43 am]
The Silver Coder on YouTu...
by
silvercoder70
[December 12, 2024, 11:42:06 pm]
crash db navigator with L...
by
wp
[December 12, 2024, 11:07:46 pm]
Common File Dialogs Have ...
by
dsiders
[December 12, 2024, 11:02:19 pm]
[Solved] Crosshair error ...
by
wp
[December 12, 2024, 10:45:16 pm]
Datatypes Interoperabilit...
by
BSaidus
[December 12, 2024, 09:36:52 pm]
Component Installation
by
msch
[December 12, 2024, 09:31:43 pm]
Who catches the Linux sig...
by
PascalDragon
[December 12, 2024, 09:10:40 pm]
Bot moderator for large g...
by
Renat.Su
[December 12, 2024, 09:09:31 pm]
FPC port to 9front
by
PascalDragon
[December 12, 2024, 09:00:02 pm]
Wiki, a dead link in page...
by
d7_2_laz
[December 12, 2024, 08:47:40 pm]
lazarus 4.0 RC1 error
by
Martin_fr
[December 12, 2024, 08:06:35 pm]
Help Needed With FPHTTPCl...
by
AaronCatolico1
[December 12, 2024, 06:46:06 pm]
Draw Transparent Fill Rec...
by
LBox
[December 12, 2024, 06:43:14 pm]
I have created dll in gol...
by
Packs
[December 12, 2024, 05:52:32 pm]
Interaction dbnavigator r...
by
calm_sea
[December 12, 2024, 03:08:52 pm]
Online tutor using remote...
by
marcov
[December 12, 2024, 10:21:25 am]
had a question and found ...
by
MarkMLl
[December 12, 2024, 09:14:59 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [Solved]How to programmatically determine if an external .exe has embedded icons (Read 2861 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: 614
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: 6591
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: 614
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: 6591
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