Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Replace an Executable's icon at runtime ??

Posted on 1999-07-08
37
Medium Priority
?
213 Views
Last Modified: 2010-07-27
Hello fellow delphians,

Does anyone of you know I can change the icon of a delphi made program, with another delphi made program.

The same like let's say Microangelo can do.

I think i have to do some binary writing on the exe file, but at what offset, and what format ??

Hope you can help me out on this.
Thanks in advance,
mories
0
Comment
Question by:mories
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 15
  • 13
  • 4
  • +4
37 Comments
 
LVL 3

Expert Comment

by:Slavak
ID: 1387177
Hi,

I don't know what Microangelo does, but you can change icon of exe file directly in resource.

Regards.
0
 
LVL 1

Author Comment

by:mories
ID: 1387178
I want to create a program (A) which can replace the icon in the another exe (B) Both programs are written by me, but the user must have the option to the change the icon in (B) at runtime of (A).

Thanx.
mories
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1387179
Sorry, this is only possible on NT. Forget about it on 95/98.

Epsylon.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:mories
ID: 1387180
hmmm, epsylon, I know about the functions UpdateResource etc. on NT. That doesn't work on W9x ofcourse.

But it has to be possible because there are some icon editors etc. which can do this.

But the problem is that I wan't to do this from my own program.

Mories
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1387181
What you can do in your program is loading the icon from a .ico file at startup. You can change/replace the .ico file whenever you want.

Epsylon.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1387182
Application.Icon.LoadFromFile('Icon.ico');
0
 
LVL 1

Author Comment

by:mories
ID: 1387183
Oke, i know about the ico loading, but I want the users to view the new icon in the explorer etc.  So it has to be replaced in the Exe.

Mories
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1387184
Which icon editors do this? I possible please give me a URL where I can Download one.....
0
 
LVL 1

Author Comment

by:mories
ID: 1387185
Microangelo can do this...

www.impactsoft.com
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1387186
hi mories,
really, can microangelo change the icon of a running exe?
meikl
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1387187
I can't try it because I work on NT right now but I didn't find anything in the info.
0
 
LVL 1

Author Comment

by:mories
ID: 1387188
How about my original question ;-)....

(nope i think it can't be done when exe is running)

Does anyone have a suggestion for my original qeustion, before this becoming a Microangelo Thread..
0
 
LVL 1

Author Comment

by:mories
ID: 1387189
The Icon doesn't need to be replaced in a running program, but BY a running program, in another "not running" exe.

On binary level, the .rsrc segment in the exe, but I don't have a clue on which offset to write, or in which format..
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1387190
There are API functions to modify resources in exe files but they only work on NT.

It just can't be done unless you use a terrible hack but I don't think anyone around here knows how to do that. This same question has been asked many times before and I never saw a solution.

Epsylon.
0
 
LVL 2

Expert Comment

by:CalvinDay
ID: 1387191
I use a component KGSExeAttachment by Krassimire Stoyanov that allows you to modify the program exe from another program. You can extract Icons, Pictures and even other programs. Here's where you can get it. It has a great demo.

http://www.xs4all.nl/~dgb/delnew.html
0
 
LVL 1

Author Comment

by:mories
ID: 1387192
Hi CalvinDay,

i know the component you are talking about. But that is not the component i mean. You cannot replace the MAINICON resource in an exe with it. What it does is add/extract additional files to an exe.

I have already talked to Krassimire, he has another component which can replace an icon. (it is not on his site)
This component is for sale for $55. Not that I don't want to buy it, but i just want to know how to do this myself.

And for a small program like mine, $55 is not worth it i guess...
0
 
LVL 2

Expert Comment

by:CalvinDay
ID: 1387193
I guess you are right. The icon in the explorer or on the desktop would still be wrong.
0
 
LVL 1

Author Comment

by:mories
ID: 1387194
Hmm, it seems to be a difficult problem to solve.. !!

Increasing the points to 400
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1387195
mories, why don't you use a separate ICO file... when the user chooses which file he want's you simply copy that file to your directory and rename it to a name specified by you... then you can simply set the icon to that file...
0
 
LVL 1

Author Comment

by:mories
ID: 1387196
;-)

The main problem is that the file needs to have the new icon when seen in ther explorer etc...
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1387197
oh you mean that icon... the best thing to do is go to sysinternals.com and get the FileMon and try using that program of yours that can do that.... then simply save the contents of the ListView form FileMon to a file, and start searching for the write() functions in the file and the offset to where it's been written.. sorry, it's kinda late here so I don't even know what i'm tpying now :))

-vik-
0
 
LVL 1

Author Comment

by:mories
ID: 1387198
Yes, i know exactly what you mean, I've already tried that.
I found the offset, I a see there are 2216 bytes(or something like that) written, but how do I write them,
not how but in which format.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1387199
just write it in binary mode... :)) let's hope it'd work... first of all, you might have to create a header structure for the ICON file, and the rest of it should probably be the data.... you should read on ICO files... try wot's it format website...

-vik-
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1387200
Mories, do you have code to locate the existing icon in the exe?
0
 
LVL 1

Author Comment

by:mories
ID: 1387201
Hmm, I think I do, there is a demo called resexplor in the delphi directory. This one looks for all the resources in an exe. And also gives the offset of the Icon resource.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1387202
That won't work, I already looked at that demo.

With the right offset I may have a solution for it.
0
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1387203
Mories,

How about an absolutely goofy way of accomplishing the same thing? Eats up space, it isn't pretty and it's a hack from hell but it might solve your problem.

Create TWO executables, each with it's own icon and have program #1 change the shortcut to Program #2 to point to the application with the different icon (EXE #1 or EXE #2) or vice-versa?

Just a thought from the peanut gallery!

Good Luck with your project
Pegasus
0
 
LVL 1

Author Comment

by:mories
ID: 1387204
Epsylon, do you still have a solution for this. Please contact me if you do at mories@mories.com
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1387205
I may only have a solution for it if I knew a way to find the current icon in the executable. But I don't know that....
0
 
LVL 1

Author Comment

by:mories
ID: 1387206
I have a unit specially for a PE header the exe file format, and I think this will find the icon in an exe.

0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1387207
If you could send that unit to epsylon3@hotmail.com I will try it...
0
 
LVL 1

Author Comment

by:mories
ID: 1387208
Unit is send...
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1387209
do you mind sending it to me too? THanks!

btw, I'm sure that wot's it format has it all, but i'm too damn lazy to reseaerch this topic... as usually ;)
0
 
LVL 1

Author Comment

by:mories
ID: 1387210
Epsylon,

Did you find anything on the offset problem ?

If you add an answer to this question, you'll get the points anyway.

Thank you very much !
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 1200 total points
ID: 1387211
Thank you, Mories, I appreciate that!
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1387212
I can find some icons but I can't find the right ones. And I use some terrible hacks. The problem is that an application can have multiple icons for different color depths.....
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1387213
I mean that I got it working for 'calc.exe' but not for 'iexplore.exe' for example and it's not relyable.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question