Removed the unnecessary Stdcall statements and modified the batch file to handle correctly the object module with objconv 64bit :
Build.bat
Code: Select all
\FreeBASIC\fbc -nodeflibs -c BugIcon.bas
IF EXIST \MinGW32\bin\objcopy.exe \MinGW32\bin\objcopy --remove-section .fbctinf --remove-section .ctors BugIcon.o
\FreeBASIC\bin\win32\ld -e _WinMainCRTStartup -subsystem windows -o BugIcon.exe BugIcon.o -L\FreeBASIC\lib\win32 -lkernel32 -luser32 -lgdi32 -lmsvcrt -s
\FreeBASIC\fbc -arch 64 -nodeflibs -c BugIcon.bas -o BugIcon64.o
IF EXIST \MinGW64\bin\objcopy.exe \MinGW64\bin\objcopy --remove-section .rdata$zzz --remove-section .ctors --remove-section .fbctinf BugIcon64.o
\FreeBASIC\bin\win64\ld -e WinMainCRTStartup -subsystem windows -o BugIcon64.exe BugIcon64.o -L\FreeBASIC\lib\win64 -lkernel32 -luser32 -lgdi32 -lmsvcrt -s
Code: Select all
#include once "windows.bi"
#include once "crt.bi"
#ifdef __FB_64BIT__
#define CallConvention
#else
#define CallConvention Cdecl
#endif
Type ICONDIRENTRY field=1
bWidth As UByte
bHeight As UByte
bColorCount As UByte
bReserved As UByte
wPlanes As UShort
wBitCount As UShort
dwBytesInRes As ULong
dwImageOffset As ULong
End Type
Type ICONDIR field=1
idReserved As UShort
idType As UShort
idCount As UShort
idEntries As ICONDIRENTRY
End Type
Declare Function WinMain Alias "WinMain" () As Any Ptr
Sub WinMainCRTStartup CallConvention Alias "WinMainCRTStartup"()
WinMain()
ExitProcess(0)
End Sub
Function WinMain Alias "WinMain" () As Any Ptr
Dim As HICON hIcon
Dim As Integer _width,height
Dim As HDC hDesktop
Dim As SYSTEMTIME st
Dim As Uinteger i
Dim As ICONDIR Ptr IconInfo
Asm
push OFFSET icondata
pop [IconInfo]
End Asm
hIcon=CreateIconFromResource(Cast(PBYTE,IconInfo)+IconInfo->idEntries.dwImageOffset,_
IconInfo->idEntries.dwBytesInRes,1,&H30000)
_width=GetSystemMetrics(SM_CXSCREEN)
height=GetSystemMetrics(SM_CYSCREEN)
hDesktop=GetDC(0)
GetSystemTime(@st)
For i=0 To st.wMilliseconds
rand()
Next i
For i=0 To 500
DrawIcon(hDesktop,rand() Mod _width,rand() Mod height,hIcon)
_sleep(10)
Next i
ReleaseDC(0,hDesktop)
Function=0
End Function
Asm
.data
icondata:
.byte 0,0,1,0,1,0,31,32,16,0,0,0,0,0,232,2
.byte 0,0,22,0,0,0,40,0,0,0,31,0,0,0,64,0
.byte 0,0,1,0,4,0,0,0,0,0,128,2,0,0,96,0
.byte 0,0,97,0,0,0,16,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,128,0,0,128,0,0,0,128,128,0,128,0
.byte 0,0,128,0,128,0,128,128,0,0,192,192,192,0,128,128
.byte 128,0,0,0,255,0,0,255,0,0,0,255,255,0,255,0
.byte 0,0,255,0,255,0,255,255,0,0,255,255,255,0,255,255
.byte 255,255,255,255,0,0,0,15,255,255,255,255,255,240,255,0
.byte 0,255,255,0,0,0,0,0,15,255,240,0,15,240,240,0
.byte 15,255,240,0,0,0,0,0,0,255,255,0,0,240,6,96
.byte 255,255,0,230,230,0,6,230,224,15,255,240,102,0,6,224
.byte 255,240,14,110,110,96,110,110,110,0,255,240,230,0,6,0
.byte 255,240,230,239,230,224,230,239,230,224,255,240,6,0,240,230
.byte 15,14,110,254,254,96,110,254,254,110,15,6,224,240,240,246
.byte 15,6,239,238,239,224,239,238,239,230,15,6,240,240,240,230
.byte 15,14,254,238,238,96,110,238,238,110,15,6,224,240,240,254
.byte 96,0,239,238,239,224,239,238,239,224,0,110,240,240,255,15
.byte 230,96,254,238,238,96,110,238,238,96,102,239,15,240,255,240
.byte 14,240,239,238,239,224,239,238,239,224,254,0,255,240,15,255
.byte 240,0,254,238,238,96,110,238,238,96,0,255,255,0,0,255
.byte 255,240,239,254,239,224,239,254,239,224,255,255,240,0,0,15
.byte 240,0,14,254,238,96,110,254,238,0,0,255,0,0,15,224
.byte 14,246,15,254,239,224,239,254,239,6,254,0,239,0,240,15
.byte 224,0,14,254,238,96,110,254,238,0,0,239,0,240,255,240
.byte 15,255,14,255,239,224,238,255,239,15,255,0,255,240,255,255
.byte 255,240,14,239,254,96,110,239,254,0,255,255,255,240,255,255
.byte 255,6,0,238,224,0,0,238,224,6,15,255,255,240,255,255
.byte 255,15,0,0,14,254,254,0,0,15,15,255,255,240,240,255
.byte 240,0,15,0,111,255,230,96,15,240,240,255,240,240,0,255
.byte 15,224,255,255,14,254,254,15,255,240,239,15,240,0,6,15
.byte 14,15,255,240,0,0,0,0,255,255,14,15,6,0,14,240
.byte 255,15,255,0,240,14,0,240,15,255,15,224,254,0,240,224
.byte 240,255,240,6,254,0,14,246,0,255,240,240,224,240,255,0
.byte 15,255,240,102,255,224,239,246,96,255,255,0,15,240,255,255
.byte 255,255,240,6,254,0,14,246,0,255,255,255,255,240,255,255
.byte 255,255,255,0,224,0,0,224,15,255,255,255,255,240,255,240
.byte 255,255,240,0,0,0,0,0,0,255,255,240,255,240,255,255
.byte 15,255,0,255,255,0,15,255,240,15,255,15,255,240,255,255
.byte 240,0,255,255,255,255,255,255,255,240,0,255,255,240,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0
.text
End Asm