borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (2d interior design)Next Topic (Inserting Column Fields to existing Table) New Topic New Poll Post Reply
AndreaVB Forum : VB General : How can I delete a printer
Poster Message
mcorben
Level: Whizz Kid

Registered: 31-05-2005
Posts: 16

icon How can I delete a printer

How can I delete a printer in VB 6 with XP. I want to print to it and then remove it

03-03-2006 at 06:32 PM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: How can I delete a printer

YOu will need next 3 API's for deleting printer

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

Private Declare Function OpenPrinter Lib "winspool.drv" _
   Alias "OpenPrinterA" _
   (ByVal pPrinterName As String, _
   phPrinter As Long, _
   pDefault As Any) As Long
  
Private Declare Function DeletePrinter Lib "winspool.drv" _
   (ByVal hPrinter As Long) As Long
  
Private Declare Function ClosePrinter Lib "winspool.drv" _
   (ByVal hPrinter As Long) As Long


1) first you use OpenPrinter API to get a handle of printer that tou want to delete
2) pass this handle to DeletePrinter API
3) Pass this handle to ClosePRinter API to free the resources

I played with this API's long time ago, so I am not sure if you will need to pass data type to PRINTER_DEFAULTS pDatatype string. IF yes, then you need to check in printer's properties what is the datatype (ex RAW), and you will set pDataType string to "RAW".

P.S. PRINTER_DEFAULTS structure is passed as the pDfaults parameter... I believe the rest would be fairly easy...

____________________________
If you find the answer helpful, please mark this topic as solved.

05-03-2006 at 12:41 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : How can I delete a printer
Previous Topic (2d interior design)Next Topic (Inserting Column Fields to existing Table) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder