How to Add a Printer to NT/95 and Make it the Default Printer
Keywords: default printer
Question:
I need to automate adding a new network printer in Win95/NT, and make it the default
printer. Can this be done? How?
Answer:
See the Printer Control Extender function pAddPrinter.
pAddPrinter adds a printer to the list of supported printers for a server.
Syntax:
pAddPrinter(server-name, printer-name, port-name, driver-name, print-processor)
Parameters:
(s) server-name In Windows 95, this is not used, and should be set to "".
You can only add printers for the local machine. In
Windows NT, this specifies the machine on which to
create the printer. The caller must have admistrative
access to the server. You can specify "" for the local
machine.
(s) printer-name the name you want for the newly-added printer.
(s) port-name printer port. (ie., LPT1)
(s) driver-name must be the name of an already-installed driver. This
should be the driver's display name (eg, as shown in
the pull-down listbox for "Print using the following driver"
under a printer's properties), not the file name.
(s) print-processor will almost always be "WinPrint".
Returns:
(i) 1 on success, or a negative error code on failure.
Note that this function may take a minute or so to complete.
Example:
AddExtender("WWPRT34I.DLL")
pAddPrinter("", "My new printer", "LPT1:", "HP LaserJet 4", "WinPrint")
Article ID: W13681
Filename: Add a Printer to NT-95 and Make it the Default Printer.txt