Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW TO GET THE DEFAULT PRINTER

Status
Not open for further replies.

sebseb12

Programmer
Dec 3, 2002
18
FR
How can I get the default printer name or hdc...

I need it for All-plateform...

Any idea without going in the deep of the API....
 
You can try using the Printer object. It has a property call .hDC.

Here is a sample of how to get the name of all avaialble printers to a list box using the printer object.

Dim p As Printer

For Each p In Printers
lstNames.AddItem p.DeviceName
Next
Thanks and Good Luck!

zemp
 

To get the default printer name and hdc just use...
[tt]
Dim PrinterName As String, PrinterHDC As Long

PrinterName = Printer.DeviceName
PrinterHDC = Printer.hdc
[/tt]

Good Luck

 
Sorry, it doesn't work vb5prgrmr...

Indeed, this hdc property can change during execution so I can't fixe it in a variable to get it after.

Any other idea ?
 
Use this:
Declare Function GetPrinter Lib "winspool.drv" Alias "GetPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, buffer As Long, ByVal pbSize As Long, pbSizeNeeded As Long) As Long
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top