How to include .ico in executable
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
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.
Bye
Mike
Tranquilizer/ Secretly!
Registred PureBasic User
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.

Bye
Mike
Tranquilizer/ Secretly!
Registred PureBasic User
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
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!?
So all our programs will have a more professional touch... Here is a small codesnip for cor... have fun...
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
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!?

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"
greetz
MrVainSCL! aka Thorsten
Edited by - MrVainSCL on 08 January 2002 17:50:38
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Rings.
MrVainSCL write
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
MrVainSCL write
???? Garbage,UNSINN !So all our programs will have a more professional touch...
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
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
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)
Code: Select all
Inc_SysTrayIcon:
IncludeBinary "YourSysTrayIconFile.ico"
LoadImage(0,?Inc_SysTrayIcon)
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)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
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
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....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.
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
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by cor.
Paul,
Thats a great solution
Thanks
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Paul,
Thats a great solution
Thanks
Registered user of PBNot 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 )
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Don.
- 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
A few things to watch out for ...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 )
- 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
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
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"
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
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"

PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Rings.
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 .
Siggi
vlink is already packed with upx self.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!)
Milliseconds doesn't matterHey, 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?
I want those 'functions' too.the included stuff "IncludeBinary()" directly by something like "DecodeXXX"Hope you can understand me now a little bit more!? Anyway nice work you have done!
I will work on that and correct the PE-Header(And Checksum).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 agree, but work on a solution.when the data is included and loaded into the memory too, why should i save and load it again into memory
Thats what xTract want to prevent(See Password protection).Maybe i still want modify something with a HexEditor or something else in the file!
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 .
okay i will be quit now, its just a forum for programming tips and hints.! So please dont be fighted...
Siggi