Solved

Adding Printers in VB

Posted on 2000-05-03
4
283 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protecting vb6 & .Net code Obfuscation 18 210
Zip Folders Using Chilkat Routines 1 86
VB6 - Scroll Mouse wheel on Picturebox 13 118
Dinamic report to Crosstab query 9 59
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

737 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