Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
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.
|