Archived from groups: microsoft.public.windowsnt.print (More info?)
I have to be able to programitically set up a printer without user
intervention for some remote setup things I am doing. I am using
AddPrinter() and all is working well if the port specified in the
PRINTER_INFO_2->pPortName exists. However, in one scenario I must deal with
it does not.
I need to do the programmatic equivalent of the step in the "Add Printer
Wizard" process where, after I select a local printer and press "Next" I am
on the "Select the Printer Port" dialog and I select "Create a new port",
select "local port" from the dropdown and press "Next", where it asks for
the port name. At this point I plug in some unique string to create a new
"port".
Here is my dilemma. If I do the Win32 AddPrinter() I must have an existing
printer port defined or the call will fail. So, so far as I can tell I must
call XcvData() if I do not want a box to pop up to get info from the user.
This is especially important since there will be no user. However, the
XcvData parameter 1 is a caller supplied printer handle which I don't yet
have since I cannot call AddPrinter to get the printer handle without the
XcvData(). It seems to be a chicken and egg situation. Am I missing
something?
You are about to answer a thread that has been inactive for more than 6 months. If you still wish to proceed, please ensure that your posting is original and does not duplicate or overlap any prior responses to this thread.