it works only with freebasic 64bits not with freebasic 32bits
i've tested on different os 32 bits , xp , vista , 7 it does not compile (tested with versions .24 ; 1.05 ; last 1.06)
on 64 bits os win 10 using fb32 : it also does not compile
but on 64 bits os win 10 using fb64 : it compiles fine (tested with versions 1.05 and last 1.06)
i even tested with -gen gcc without success
code to test
Code: Select all
#include once "windows.bi"
#include once "win\winspool.bi"
Function get_defp()as string
dim szPrinter0 AS zSTRING * 250
dim cchBuffer AS DWORD
dim retp as long
dim sret as string
cchBuffer = 250
retp = GetDefaultPrinter( @szPrinter0, @cchBuffer)
if retp THEN sret = left(szPrinter0, cchBuffer -1)
return sret
END FUNCTION
Function set_defp(ByRef sp as string )as long
dim retp as long = SetDefaultPrinter(strptr(sp))
return retp
END function
dim as string init0
init0 = get_defp() 'store current default printer
MessageBox 0, "Current default printer : " & init0 , "Printer", MB_SETFOREGROUND
if init0 <> "Microsoft Print to PDF" THEN
set_defp("Microsoft Print to PDF") ' change default printer
MessageBox 0, "Changed default printer to : " & get_defp() , "Printer", MB_SETFOREGROUND
sleep 150
set_defp(init0) ' restore current default printer
MessageBox 0, "Restored default printer to : " & get_defp() , "Printer", MB_SETFOREGROUND
sleep 150
END IF
sleep 400
Code: Select all
"D:\freebasic\FreeBASIC-1.05.0-win32\fbc.exe" -x "D:\freebasic\print_pdf\select_printer0.exe" -s console -v select_printer0.bas > select_printer0.log 2>&1
FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win32 (32bit)
Copyright (C) 2004-2016 The FreeBASIC development team.
standalone
target: win32, 486, 32bit
compiling: select_printer0.bas -o select_printer0.asm (main module)
assembling: D:\freebasic\FreeBASIC-1.05.0-win32\bin\win32\as.exe --32 --strip-local-absolute "select_printer0.asm" -o "select_printer0.o"
linking: D:\freebasic\FreeBASIC-1.05.0-win32\bin\win32\ld.exe -m i386pe -o "D:\freebasic\print_pdf\select_printer0.exe" -subsystem console "D:\freebasic\FreeBASIC-1.05.0-win32\lib\win32\fbextra.x" --stack 1048576,1048576 -s -L "D:\freebasic\FreeBASIC-1.05.0-win32\lib\win32" -L "." "D:\freebasic\FreeBASIC-1.05.0-win32\lib\win32\crt2.o" "D:\freebasic\FreeBASIC-1.05.0-win32\lib\win32\crtbegin.o" "D:\freebasic\FreeBASIC-1.05.0-win32\lib\win32\fbrt0.o" "select_printer0.o" "-(" -lkernel32 -lgdi32 -lmsimg32 -luser32 -lversion -ladvapi32 -limm32 -lwinspool -lfb -lgcc -lmsvcrt -lmingw32 -lmingwex -lmoldname -lgcc_eh "-)" "D:\freebasic\FreeBASIC-1.05.0-win32\lib\win32\crtend.o"
select_printer0.o:fake:(.text+0x123): undefined reference to `SetDefaultPrinterA@4'
linking failed: 'D:\freebasic\FreeBASIC-1.05.0-win32\bin\win32\ld.exe' terminated with exit code 1
comments welcome