Not a Member Yet,
Click here to Register
How do you like the new design?
It's cool, great job
[tally: 70%] 70%
It's okay
[tally: 20%] 20%
Its OK but I liked the old layout better
[tally: 0%] 0%
Please bring the old one back
[tally: 10%] 10%

votes: 10

ID: 416
Viewed: 2413
Added: Aug 19, 2002
Version:
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

The followong code change the default printer. It works only on Windows95/98

Highlight all by clicking in box
<!---Declaration--->
'Declare

Public Const CCHDEVICENAME = 32
Public Const CCHFORMNAME = 32
Public Const PRINTER_ATTRIBUTE_DEFAULT = &H4



Type PRINTER_INFO_5
pPrinterName As String
pPortName As String
Attributes As Long
DeviceNotSelectedTimeout As Long
TransmissionRetryTimeout As Long
End Type



Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type



Type PRINTER_DEFAULTS
pDatatype As String
pDevMode As DEVMODE
DesiredAccess As Long
End Type



Declare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" (ByVal hPrinter As Long,
ByVal Level As Long, pPrinter As PRINTER_INFO_5, ByVal Command As Long) As Long

Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As
String, phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long


Highlight All
<!---Code--->
Public Function SetDefaultPrinter(PrinterName As String) As Boolean

Dim phPrinter As Long
Dim pDefault As PRINTER_DEFAULTS
Dim pInfo5 As PRINTER_INFO_5
Dim Ret As Long

Ret = OpenPrinter(PrinterName, phPrinter, pDefault)

If phPrinter <> 0 Then

pInfo5.pPrinterName = PrinterName

pInfo5.Attributes = PRINTER_ATTRIBUTE_DEFAULT

Ret = SetPrinter(phPrinter, 5, pInfo5, 0)

If Ret <> 0 Then

SetDefaultPrinter = True

Else

SetDefaultPrinter = False

End If

Else

SetDefaultPrinter = False

End If

End Function;


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2017 snippetlibrary.com All Rights Reserved. Conditions