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
VisualPlainIT and Postgre...
by
kkuba
[
Today
at 03:04:40 pm]
Compiler Callback API => ...
by
marcov
[
Today
at 02:00:29 pm]
Poor optimization of cons...
by
Martin_fr
[
Today
at 01:54:09 pm]
Notarization under macOS ...
by
TRon
[
Today
at 12:58:30 pm]
Intercept multimedia keys
by
Espectr0
[
Today
at 12:02:20 pm]
Looking for property (boo...
by
wp
[
Today
at 11:44:09 am]
Initialize Form Variable?
by
marcov
[
Today
at 11:25:49 am]
Feature announcement: Fun...
by
bytebites
[
Today
at 10:24:42 am]
Custom PopUp Menu with Co...
by
madref
[
Today
at 09:38:50 am]
failed to create named pi...
by
MarkMLl
[
Today
at 08:49:40 am]
TScroollBar vs TControlSc...
by
simsee
[
Today
at 08:23:46 am]
Building static libraries...
by
Fibonacci
[
Today
at 04:15:55 am]
Web assembly in Lazarus
by
PierceNg
[
Today
at 02:54:17 am]
Online Package Manager
by
Beazy
[October 03, 2023, 11:22:22 pm]
Tmenuitem of TpopopMenu
by
paweld
[October 03, 2023, 11:06:26 pm]
fpsStreams unit problems
by
wp
[October 03, 2023, 10:44:02 pm]
Disable sse/avx
by
marcov
[October 03, 2023, 10:43:02 pm]
Component for generating ...
by
colo
[October 03, 2023, 08:58:24 pm]
Wayland and Free Pascal
by
nouzi
[October 03, 2023, 07:54:01 pm]
LAMW - opening URL in ext...
by
c4p
[October 03, 2023, 06:37:06 pm]
TBufferedFileStream crash...
by
AlexTP
[October 03, 2023, 06:13:54 pm]
FPImageException while l...
by
wp
[October 03, 2023, 05:05:57 pm]
What is a .DB file
by
wp
[October 03, 2023, 04:13:15 pm]
IntraWeb in Lazarus??
by
ginoo
[October 03, 2023, 01:32:49 pm]
Pull an icon from a runni...
by
BIT
[October 03, 2023, 01:10:29 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [Solved]How to programmatically determine if an external .exe has embedded icons (Read 540 times)
Ten_Mile_Hike
New Member
Posts: 27
[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: 166
#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: 5510
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: 166
#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: 5510
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: 27
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