Solved

Adding Printers in VB

Posted on 2000-05-03
4
279 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now