Page 1 of 1
Printer selection
Posted: Tue Jul 27, 2004 9:22 am
by schim
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
Posted: Tue Jul 27, 2004 9:54 am
by fweil
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
Re: Printer selection
Posted: Tue Jul 27, 2004 3:51 pm
by gnozal
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
I think this should work with all Windows versions :
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
Posted: Tue Jul 27, 2004 11:01 pm
by swan
Thanx Gnozal. I had been trying to do this as an exercise for a couple of weeks now. It had stumped me.
SWAN ...