API AddPrinterConnection 
Author Message
 API AddPrinterConnection

I'm having some difficulties getting the function to work.

I have declared the function as follows:

Declare Function AddPrinterConnection Lib "spoolss.dll" Alias _
"AddPrinterConnectionA" (ByVal pName As String) As Long

The code I'm trying to run is as follows:

Private Sub AddPrinter(sPrinter As String)
Dim lRetVal As Long
Dim sPrinterName As String

sPrinterName = Left$(sPrinter, InStr(sPrinter, "=") - 1) & Chr$(0)

lRetVal = AddPrinterConnection(sPrinterName)
End Sub

The sPrinter variable passed to the Sub is a UNC format printer location
e.g.
\\myserver\printer

Unfortunately, nothing happens. The return value is zero (indicating
failure) and sure enough, no printer is added to the machine. That's about
all I get.

Any help would be well appreciated.


Simon



Mon, 11 Sep 2000 03:00:00 GMT  
 API AddPrinterConnection

Hi,

As far as I've understood this API it just adds a connection (Port), not a
printer.
(The "port" must exist prior to making the call, else the API will fail.)
If Your call returns successfully You should be able to see the "port" if
You look at another installed printer's port-tab in it's properties form.
If You need to add a printer then You must use the AddPrinter API (this
printer can then be set up to print to the "port" added by AddConnection.)

 Per



Quote:
> I'm having some difficulties getting the function to work.

> I have declared the function as follows:

> Declare Function AddPrinterConnection Lib "spoolss.dll" Alias _
> "AddPrinterConnectionA" (ByVal pName As String) As Long

> The code I'm trying to run is as follows:

> Private Sub AddPrinter(sPrinter As String)
> Dim lRetVal As Long
> Dim sPrinterName As String

> sPrinterName = Left$(sPrinter, InStr(sPrinter, "=") - 1) & Chr$(0)

> lRetVal = AddPrinterConnection(sPrinterName)
> End Sub

> The sPrinter variable passed to the Sub is a UNC format printer location
> e.g.
> \\myserver\printer

> Unfortunately, nothing happens. The return value is zero (indicating
> failure) and sure enough, no printer is added to the machine. That's
about
> all I get.

> Any help would be well appreciated.


> Simon



Wed, 13 Sep 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problem with AddPrinterConnection

2. AddPrinterConnection in Win2000 Server

3. WSH 2.0 and the AddPrinterConnection ?

4. addprinterconnection

5. DeletePrinterConnection, AddPrinterConnection

6. Getting AddPrinterConnection Error

7. AddPrinterConnection fails: 1797: Unknown printer driver

8. AddPrinterConnection

9. Getting AddPrinterConnection Error

10. API API API

11. API, API, Who's got the API

12. releaseCapture API and send message API.

 

 
Powered by phpBB® Forum Software