Hi!
How can I select a printer without using the print requester?
Default printer works, but I have to set diffrent printers.
There is an example but it only works on W2K (or W98) because the script grapped out the printernames from the win.ini-File.
Perhaps someone has a solution?
Thanks
schim
Printer selection
I guess you can start reading this for example.
viewtopic.php?t=11834&start=0&postdays= ... highlight=
Then come back with more questions if needed.
Rgrds
viewtopic.php?t=11834&start=0&postdays= ... highlight=
Then come back with more questions if needed.
Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: Printer selection
I think this should work with all Windows versions :schim wrote:Hi!
How can I select a printer without using the print requester?
Default printer works, but I have to set diffrent printers.
There is an example but it only works on W2K (or W98) because the script grapped out the printernames from the win.ini-File.
Perhaps someone has a solution?
Thanks
schim
Code: Select all
NewList Imprimantes.s()
Procedure.l GetInstalledPrinters() ; in linked list Imprimantes()
ClearList(Imprimantes())
Buffersize.l = 8102
*Buffer = GlobalAlloc_(#GMEM_FIXED | #GMEM_ZEROINIT, Buffersize)
TempPrinter.s = Space(1024)
If GetProfileString_("devices", 0, "", *Buffer, Buffersize)
TempString.s = PeekS(*Buffer)
Length.l = Len(TempString)
While TempString <> ""
GetPrivateProfileString_("devices", TempString, "", TempPrinter, 1024, "Win.Ini")
; Debug "Device : " + TempString
; Debug "Driver : " + StringField(TempPrinter,1,",")
; Debug "Port : " + StringField(TempPrinter,2,",")
AddElement(Imprimantes())
Imprimantes() = TempString
TempString = PeekS(*Buffer + Length + 1)
Length = Length + Len(TempString) + 1
Wend
EndIf
GlobalFree_(*Buffer)
ProcedureReturn CountList(Imprimantes())
EndProcedure
;
Procedure.s GetDefaultPrinter()
STDPrinterName$ = Space(260)
If GetPrivateProfileString_("WINDOWS","DEVICE","", @STDPrinterName$, 260, "Win.Ini")
ImprimanteParDefaut.s = StringField(STDPrinterName$, 1,",")
EndIf
ProcedureReturn ImprimanteParDefaut
EndProcedure