• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

Adding Printers in VB

what API calls can i make to add a printer driver through VB code?  Please give a brief explain of each api call and/or sample source code. Thanks! (VB6, Win98)

0
tylerd
Asked:
tylerd
  • 2
1 Solution
 
RuchiCommented:
"HOWTO: Connect to a Network Printer with the Win32 API"

http://support.microsoft.com/support/kb/articles/Q154/0/07.asp

"Add new printers"
http://www.vbsquare.com/tips/tip409.html
0
 
tylerdAuthor Commented:
thats not quite what im looking for...i need to be able to add the printer without any user interaction.
0
 
AzraSoundCommented:
it would only require one api call

Public Declare Function AddPrinter Lib "winspool.drv" Alias "AddPrinterA" (ByVal pName As String, ByVal Level As Long, pPrinter As Any) As Long


Level must = 2

pPrinter points to printer structure:

Public Type PRINTER_INFO_2
        pServerName As String
        pPrinterName As String
        pShareName As String
        pPortName As String
        pDriverName As String
        pComment As String
        pLocation As String
        pDevMode As DEVMODE
        pSepFile As String
        pPrintProcessor As String
        pDatatype As String
        pParameters As String
        pSecurityDescriptor As SECURITY_DESCRIPTOR
        Attributes As Long
        Priority As Long
        DefaultPriority As Long
        StartTime As Long
        UntilTime As Long
        Status As Long
        cJobs As Long
        AveragePPM As Long
End Type
0
 
AzraSoundCommented:
if you are using Win95/98 then the pName parameter of the function is null, as it references the server name (and under Win95/98 you can only add local printers).  i havent seen vb code anywhere yet that uses this function but the general info regarding it can be found at:

http://msdn.microsoft.com/library/psdk/gdi/prntspol_1po2.htm
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now