Printer selection

Windows specific forum
schim
New User
New User
Posts: 1
Joined: Tue Jul 27, 2004 9:18 am

Printer selection

Post 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
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post 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
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.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Printer selection

Post 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
swan
Enthusiast
Enthusiast
Posts: 225
Joined: Sat Jul 03, 2004 9:04 am
Location: Sydney Australia
Contact:

Post 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 ...
Post Reply