PDA

View Full Version : Icon changer for bundled thinBasic files



GSAC3
05-03-2009, 00:57
Until Roberto has a chance to modify the thinBasic bundler to allow user-specified icons, here is a simple program that will allow the existing icon to be changed after a bundle has been created.

This routine was created using FBSL version 3, and is based on one originally written by Gerome Guillemin to change the icon on FBSL files. The GUI-based routine is, however, limited to the use of 32x32x16 color (766 byte) icons.

Don

Michael Hartlef
05-03-2009, 07:59
awesome :eusaclap: thank you so much

Petr Schreiber
05-03-2009, 08:05
Don,

works good!
Thank you very much!


Petr

ErosOlmi
05-03-2009, 13:08
Thanks a lot Don.

To be honest I do not like too much to have a FBSL bundled exe that change an icon in a thinBasic bundled exe, but that's it: we have to survive :D

Maybe we can make a thinBasic application that does the job. I will study it.

GSAC3
05-03-2009, 16:24
Eros:

I agree with your feelings about using a FBSL program to modify a thinBasic bundled script. I had my own misgivings about this as well, but I needed a way to get the job done and it worked. I must admit that it was pure luck that I stumbled on the capability of this routine to change icons in bundled thinBasic scripts. This was an example of serendipity in action. The only modification I made to the original FBSL procedure was the window title.

Don

ErosOlmi
05-03-2009, 17:44
The following thinBasic code does change the icon of whatever EXE.
Again: limitation to 32x32 16 colors icons

Attention: for safety reasons, original exe is never touched and a new exe is created.

Maybe someone would like to add a nice user interface and a better error checking.

Ciao
Eros



USES "FILE"
USES "UI"

'---binary marker inside the exe used to identify icon position
$IconMarker = chr$(&H28, &H00, &H00, &H00, &H20, &H00, &H00, &H00, &H40, &H00)

%ICONSTART = &h16
%ICONMAXSIZE = &h2FE

'---Ask about EXE file
DIM sExeFile AS STRING
DIM sExeBuffer AS STRING
sExeFile = Dialog_OpenFile(0, "Choose thinBasic bundled EXE", _
DIR_GetCurrent, "Exe (*.EXE)|*.EXE", "EXE", _
%OFN_FILEMUSTEXIST OR %OFN_HIDEREADONLY or %OFN_ENABLESIZING)

if sExeFile = "" then
msgbox 0, "Empty Exe file."
stop
end if

'---Ask about ICO file
DIM sIcoFile AS STRING
DIM sIcoBuffer AS STRING
sIcoFile = Dialog_OpenFile(0, "Choose Icon file", _
DIR_GetCurrent, "ICO (*.ICO)|*.ICO", "ICO", _
%OFN_FILEMUSTEXIST OR %OFN_HIDEREADONLY or %OFN_ENABLESIZING)

if sIcoFile = "" then
msgbox 0, "Empty icon file."
stop
end if

'---Full load EXE and ICO into string buffers
sExeBuffer = file_load(sExeFile)
sIcoBuffer = file_load(sIcoFile)

'---Check the sizeof the ICO
if len(sIcoBuffer) <> %ICONMAXSIZE then
msgbox 0, "Icon is not a 32x32 16 colour icon: " & str$(len(sIcoBuffer)) & str$(%ICONMAXSIZE)
stop
end if


dim lPos as long
Dim iSize as long

'---Determine where inside EXE buffer icon marker is placed
lPos = instr(sExeBuffer, $IconMarker)
if lPos = 0 then
msgbox 0, "Icon position inside EXe file not found."
stop
end if


'---If we are here it means all is ok so make some little tuning ...
iSize = len(sIcoBuffer)
If iSize > %ICONSTART Then iSize = iSize - %ICONSTART

'---...substitute current icon inside EXE buffer with the new icon data
mid$(sExeBuffer, lPos, iSize) = mid$(sIcoBuffer, %ICONSTART+1, iSize)

'---Save the new exe
file_save(sExeFile & ".exe", sExeBuffer)

'---All done.

GSAC3
05-03-2009, 18:42
Thanks Eros.

It seems to be working fine here for me.

Don

ErosOlmi
05-03-2009, 18:45
Perfect.

Motivation can let you (me) climb up any ... mountain :D

Anyhow, I'm not sure if the used method is correct or not, I do not have experience on EXE format.
I just follow FBSL example. Hope it is a safe method.

Ciao
Eros

Michael Clease
05-03-2009, 22:36
PE explorer reports it as an error, so its a hack.

I think the checksum for that chunk needs recalculating.

catventure
06-03-2009, 15:48
Until Roberto has a chance to modify the thinBasic bundler to allow user-specified icons, here is a simple program that will allow the existing icon to be changed after a bundle has been created.


Hi Don,

It worked for me on Vista - but just to say if I view folder's contents that contains the changed icon in medium or large icons display then the icon reverts back to the regular thinbasic "box" icon as normal...

Regards,
catventure.

GSAC3
06-03-2009, 16:55
catventure:

That's very interesting.

I can not repeat the effects you described on my XP SP2 system.

Don

Michael Clease
31-01-2010, 03:23
I didnt like the way the new file was created so I changed the behaviour to rename the old file and new file has the old files name.


'---Rename the old exe
FILE_Rename(sExeFile, Mid$(sExeFile,1,Len(sExeFile)-3) & "OLD.Exe")
'---Save the new exe
FILE_Save(sExeFile , sExeBuffer)

'---All done.

Petr Schreiber
31-01-2010, 09:08
Thanks Michael,

worked good here!

Maybe it would be nice to make a separate thread for your version of icon changer, keeping the first post updated with the latest release.


Petr

Michael Hartlef
31-01-2010, 09:49
Hi folks,

where the reported problems with Vista resolved?

Michael

catventure
31-01-2010, 13:08
where the reported problems with Vista resolved?


Hi Michael,

The icon changer program works. But if I change view setting in folder where icon is located from "small" icons to "tiles", "medium icons", "large icons" or "extra large icons" the thinbasic box icon reappears every time.
When I reset folder view to "small" icons - the changed icon returns!

catventure

Michael Clease
31-01-2010, 19:49
Just out of interest could you try this

http://www.botproductions.com/iconview/download.html

it looks safe but check it yourself, anyway it shows all thinbasic files as having one icon my main computer.