Solved

Adding Printers in VB

Posted on 2000-05-03
4
281 Views
Last Modified: 2010-05-02
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
Comment
Question by:tylerd
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Ruchi
ID: 2774951
"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
 
LVL 2

Author Comment

by:tylerd
ID: 2774985
thats not quite what im looking for...i need to be able to add the printer without any user interaction.
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 50 total points
ID: 2775076
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
 
LVL 28

Expert Comment

by:AzraSound
ID: 2775708
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question