AddWindowsPrinterConnection Method

 

Description

 

Adds a Windows-based printer connection to your computer system.

 

PowerBASIC Syntax

 

METHOD AddWindowsPrinterConnection ( _

BYVAL bstrPrinterName AS STRING, _

OPTIONAL BYVAL bstrDriverName AS STRING, _

OPTIONAL BYVAL bstrPort AS STRING _

)

 

Arguments

 

bstrPrinterName

BSTR. The path to the printer connection.

bstrDriverName

Optional. BSTR. The name of the driver (ignored if used on Windows NT/Windows 2000).

bstrPort

Optional. BSTR. String value specifying a printer port for the printer connection (ignored on Windows NT/Windows 2000).

 
Remarks

 

Using this method is similar to using the Printer option on Control Panel to add a printer connection. Unlike the AddPrinterConnection method, this method allows you to create a printer connection without directing it to a specific port, such as LPT1. If the connection fails, an error is thrown. In Windows 9x/Me, the printer driver must already be installed on the machine for the AddWindowsPrinterConnection method to work. If the driver is not installed, Windows returns an error message.

 

Example [PowerBASIC]

 

#INCLUDE "WSHOM.INC"

 

DIM pWshNetwork2 AS IWshNetworkw2

DIM strPrinterPath AS STRING

 

pWshNetwork2 = NEWCOM "WScript.Network"

strPrinterPath = UCODE$("\\printserv\DefaultPrinter")

pWshNetwork2.AddWindowsPrinterConnection(strPrinterPath)

 

Valid XHTML 1.0 Transitional