How to include .ico in executable

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

Is it possible to include an .ico file for systray and compile it into the executeable and how must I load this image from an executeable.



Registered user of PB

C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tranquil.

There is no dirct Command to do that, but its still possible.

The only thing you have to do is, to include your Binary at the End of your Source by the IncludeBin (something like this), give it a label and remember its filesize.

On the top of your code, just save this to a temp directory and load it again with loadimage.

By the way, there is a API Command called LoadIcon_, this should work too, not tried yet. That would be the better way and possible, most easier.

If I had time at home, I will try this. On my work I only have Windows Nt 4.0 and PB does not compile correct here. :P

Bye

Mike

Tranquilizer/ Secretly!
Registred PureBasic User
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

Hi tranquil!

You are right... Include all needed stuff and save it temporary to hd and reload it into memory, before running any application - I dont really like this way... Please Fred, please let us decode/grab (sprites, images, sound, icons....) with some new DecodeXXXX commands for the next version!? :wink: So all our programs will have a more professional touch... Here is a small codesnip for cor... have fun...

Code: Select all

 
    temp = OpenFile(0,"c:\temp.dat")
    ;  
    If temp  0
      WriteData (?Inc_SysTrayIcon,#FileSize)    
    EndIf
    ;  
    CloseFile(0)

;   Now you have to read the C:\temp.dat file...

End

;-------- Data Section --------

Inc_SysTrayIcon:
    IncludeBinary "YourSysTrayIconFile.ico"

PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...

greetz
MrVainSCL! aka Thorsten

Edited by - MrVainSCL on 08 January 2002 17:50:38
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Rings.

MrVainSCL write
So all our programs will have a more professional touch...
???? Garbage,UNSINN !
What the hell is professional touch ?

And for a easier solution take my free xTract, which link all files compressed into one when ready with coding.


Siggi
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

Code: Select all

Inc_SysTrayIcon:
IncludeBinary "YourSysTrayIconFile.ico"

LoadImage(0,?Inc_SysTrayIcon)
Fred said he will add this for the LoadImage
command, dunno if it works now.


@tranquil: LoadIcon and the other commands
load Images and Icons etc. from the Exe-Ressources.
I tried it, but didnt get it to work.

There is a free Program called "ressource hacker"
( http://rpi.net.au/~ajohnson/resourcehacker/ ).
You can add Icons and Bitmpas etc. to your
EXE Ressources, but i dont know how to access
it atm.

Maybe someone can try it.

cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.
...LoadIcon and the other commands load Images and Icons etc. from the Exe-Ressources. I tried it, but didnt get it to work.
There is a free Program called "ressource hacker" (http://rpi.net.au/~ajohnson/resourcehacker/ ).
You can add Icons and Bitmpas etc. to your EXE Ressources, but i dont know how to access it atm.
AFAIK with ResHacker you can manipulate resources but if you add resources to an application, how this application knows about that? With ResHacker you can't do that.
The normal way is a resource compiler (like gorc.exe) that makes *.rc -> *.res -> *.obj.
Than the linker (like alink.exe) has to link all together.
Something like that...


Have a nice day...
Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

Not sure if this is on topic or not but you can always use the same icon in the task bar as the one you assigned to your application when compiling with PB...

ico=ExtractIcon_(WindowID(),"appname.exe",0)
AddSysTrayIcon(1, WindowID(), ico )
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

Paul,

Thats a great solution

Thanks
Not sure if this is on topic or not but you can always use the same icon in the task bar as the one you assigned to your application when compiling with PB...

ico=ExtractIcon_(WindowID(),"appname.exe",0)
AddSysTrayIcon(1, WindowID(), ico )


Registered user of PB

C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Don.
Not sure if this is on topic or not but you can always use the same icon in the task bar as the one you assigned to your application when compiling with PB...

ico=ExtractIcon_(WindowID(),"appname.exe",0)
AddSysTrayIcon(1, WindowID(), ico )
A few things to watch out for ...

- should use GetModuleHandle_(#NULL) as the first argument in ExtractIcon_ and not WindowID().

- there's a PB v2.80 bug which I think will cause a runtime crash if you ever happen to put this in a procedure. See my comment in viewtopic.php?t=512 error&Forum_Title=Bug Reports

Don
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

Hi Rings!

Sorry... i think nothing here will be garbage (oder wie du so schön sagst, unsinn) ! So please dont be fighted...

I think i must explain you what i understand under "professional touch"!? Every coder have his own opinion what professional touch means and his own coding style... Thats ok!

Maybe you and some guys in this forum will use your xTract tool! Its surely a fast, nice and easy way to link stuff to the exefile to have no external datafiles anymore! Nice work, but there are two reasons for me, why i dont want to use your tool for my applications:


1. Its not the finest way to add/link datafiles with a tool to the end of a executeable to save all this data temporary on hd and reload it when starting the application... (Btw. when the data is included and loaded into the memory too, why should i save and load it again into memory? So i still hope that Fred will add commands to use the included sutff directly without any temporary savings! Please Fred!) In any file is a information about the original filesize... When adding some stuff, the file does not know that its now bigger and maybe some other tools, like FileTools, VirusChecks i.e could have problems with this... and maybe remove the added/linked stuff... ;(

2. I dont want that any tool will automatical pack/crunch my stuff... Maybe i still want modify something with a HexEditor or something else in the file! What is when i want to pack my application with my own or just any other public exefile packer instead of UPX? Ok,i know that its possible to decrunch it... and that UPX is in the most ways one of the best Win32 exefile packers on windows!)


Hey, are you not nerved when starting any application and when the program will save/reload first some temporary stuff to your hd and your hd is very rotating? We have so a great powerfull coding language to create cool and small professional applications - so let us please code on a nice and easy way to use the included stuff "IncludeBinary()" directly by something like "DecodeXXX" :wink: Hope you can understand me now a little bit more!? Anyway nice work you have done!

PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...

greetz
MrVainSCL! aka Thorsten
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

I agree with Mr. Vain in general terms.

Regards,

El_Choni
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tranquil.
I agree with Mr. Vain in general terms.
I'm too.

Mike

Tranquilizer/ Secretly!
Registred PureBasic User
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Rings.
What is when i want to pack my application with my own or just any other public exefile packer instead of UPX? Ok,i know that its possible to decrunch it... and that UPX is in the most ways one of the best Win32 exefile packers on windows!)
vlink is already packed with upx self.
Hey, are you not nerved when starting any application and when the program will save/reload first some temporary stuff to your hd and your hd is very rotating?
Milliseconds doesn't matter
the included stuff "IncludeBinary()" directly by something like "DecodeXXX" :wink: Hope you can understand me now a little bit more!? Anyway nice work you have done!
I want those 'functions' too.
When adding some stuff, the file does not know that its now bigger and maybe some other tools, like FileTools, VirusChecks i.e could have problems with this... and maybe remove the added/linked stuff... ;(
I will work on that and correct the PE-Header(And Checksum).
when the data is included and loaded into the memory too, why should i save and load it again into memory
I agree, but work on a solution.
Maybe i still want modify something with a HexEditor or something else in the file!
Thats what xTract want to prevent(See Password protection).
And note, the Password-Protection is not realy safe(just a few minutes to crack it) but ready for the most User (Für meine Kunden recht das aus ;SORRY PLAIN GERMAN)

And there is just a a few things to do on xTract .
! So please dont be fighted...
okay i will be quit now, its just a forum for programming tips and hints.


Siggi
Post Reply