Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Copy Executable and change icon?

Author
Message
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 27th Dec 2013 18:24 Edited at: 27th Dec 2013 18:25
Hello all!

First, I hope you had a good Christmas. I sure did!

Okay, I know how to copy and rename files. That's easy in native DBP code (without any libs), but what if I wish to change the icon of the (exe) file? Searched every documentation for every library/extension I have but couldn't find any command.

Is this even possible? If so, how would I do this?

Thanks ahead!

Regards Sph!nx
www.mental-image.net
Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 27th Dec 2013 18:51
Open your properties window under View>Toolbars>Properties and you should see the field for choosing an icon file.

D.D.
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 27th Dec 2013 21:15
Thanks, but I know that. Know many more ways to do that. But what I need to know how to do that within an application I wrote in DBP.

I use these commands to copy and rename another program I wrote:


Now my question is if there is a way to change the icon of that copied file?

Regards Sph!nx
www.mental-image.net
Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 27th Dec 2013 21:37 Edited at: 27th Dec 2013 21:37
Quote: "Now my question is if there is a way to change the icon of that copied file?"


Couldn't you tell the program to also copy and rename an .ICO file?

D.D.
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 27th Dec 2013 23:39
@ Derek Darkly
Thanks for your replies, much appreciated but I'm not sure if you understand me completely. I basically need a way to do this: "Program A" needs to copy, rename and change icon of "Program B".

Got the copying and renaming covered (easy!) but I'm clueless on the icon part.

You could copy the ico file easily and could set the window icon with that particular icon, but I don't know a command to change the exe icon that way. So far as I know, the icon is compiled in the exe file (A folder with a compiled exe does not need a lose ico file in the folder).

So I need a command, (from a plugin library or something) or another way to change exe icons from within a dbp app for another app (written in dbp as well).

Regards Sph!nx
www.mental-image.net
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th Dec 2013 15:55
Not unless you create a plugin to do it

Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 28th Dec 2013 17:12
Ah, thanks Mobiius,

That was basically my question... so no plug-in already exist? I'm afraid I'm not that great with C++, so making one myself is off the table...

Regards Sph!nx
www.mental-image.net
Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 28th Dec 2013 20:32
I think this can be done, will try to code something up later tonight if I don't fall asleep


"Why do programmers get Halloween and Christmas mixed up?"
Le Verdier
13
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 28th Dec 2013 20:49 Edited at: 28th Dec 2013 20:56
This may maybe be done in dbp but need some knowledge of the Windows API and use of windows functions inside dbp.(load dll, call dll..)

Look at the beginupdateresource function
http://msdn.microsoft.com/en-us/library/windows/desktop/ms648030(v=vs.85).aspx
I also found a small piece of code but in a weird langague unfortunatly...
http://www.developpez.net/forums/d31955/environnements-developpement/delphi/api-com-sdks/ressources-changer-icone-exe/

I don't know this topic so much, so I can't confirm if this works...
That was not a ready-to-run answer, But hope that helps a little!..

Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 28th Dec 2013 22:12
That was what I was going to propose.
Basically you would use FindResource to locate all icon resources in the executable module, then try to find the correct one (I don't know if the icon displayed for the file always appears before any other icons or not; also some executables probably just define a standard icon ID instead of containing actual bitmap resource data) and finally update the data if applicable.
The trick to doing this from DBPro is simply to create contiguous memory blocks that corresponds to the structures the winapi functions require and pass their pointers as DWORD parameters to the dll calls.


"Why do programmers get Halloween and Christmas mixed up?"
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 28th Dec 2013 22:36
Ohw wow, thanks for the effort guys, I'm a fairly confident DBP programmer, but this goes beyond me...

I understand that I need to access a dll, read that to find the icon I wish to replace and then perform that action somehow?

Regards Sph!nx
www.mental-image.net
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 5th Jan 2014 18:09 Edited at: 5th Jan 2014 18:10
- BUMP -

On more active boards I wait until the thread is off the first page, but this board is not the most active and there is a limit on how long a thread stays open after no activity... So I apologize if it is too soon.

I still need help with this... No one ever tried this before? Anyhow, any help is much appreciated!


Thanks!

Regards Sph!nx
www.mental-image.net
Le Verdier
13
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 5th Jan 2014 21:01
I'll try this.
I can't say when, so stay tuned!
(Unless someone else win the race...)

Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 6th Jan 2014 15:50
Thank you! I'll wait for it and try to contain my patience.

Regards Sph!nx
www.mental-image.net
Le Verdier
13
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 8th Jan 2014 18:04 Edited at: 8th Jan 2014 18:11
I've made some search and like you've guessed it is not as simple
as: ChangeExeIcon "MyExe.exe", "MyIcon.ico" .....

The simplest I've found is in a Microsoft example and works differently

Basically, this code reads an Icon in a source Exe and replaces (or adds if doesnt exist) An Icon in a destination Exe:




The icon are resources and have an Id number

the icons exist in several sizes, this code change only one

I used resourcehacker to read to check the ids in a dbp exe
http://www.angusj.com/resourcehacker/

Theorically, you have to check every result of the function calls
and abort if something is 0...

It seems that the icon change is not directly visible in the explorer. I first thought all had failed down,
but the change reveals after copy or rename the exe.. Dont know why.. maybe the old icons cached somewhere..
but I lack time to deepen this..

Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 9th Jan 2014 13:53
Hey mate,

Yeah I figured it would be something a little more difficult than a simple command. Even though I still can't figure it out as well, your help greatly appreciated! Thanks a lot!

Anybody else has some experience with this?

Regards Sph!nx
www.mental-image.net
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 9th Jan 2014 14:10
AH, just had an idea (that deserved a double post ).

Would it be possible to have "Program A", copy and pack "Program B" in a packed file (with custom Icon). In a way "hiding" the exe inside a file with a new icon?

Basically, the user would see 1 file with a new icon and only the packed file would need to be manipulated, not the exe. I know how to pack files fine, but would it be possible to have the pack automatically run the exe inside it when the user clicks it?

Any thoughts?

Regards Sph!nx
www.mental-image.net

Login to post a reply

Server time is: 2025-05-15 14:00:06
Your offset time is: 2025-05-15 14:00:06