We have a virtual printer (provided by a 3rd party) that is getting assigned to an invalid local printer port. The printer is always local (we aren't dealing with a remote print server or anything like that). I'd like to create a new local port (specific for our application), then configure the printer to be assigned to that port instead of the random (and often incorrect) port that the print driver installer chooses.
I believe that I need to use the XcvData and/or XcvDataPort functions to do this, but I'm at a bit of a loss as to how.
Does anyone have any examples or pointers on how to proceed?
I'd imagine that I need to do the following:
- Check to ensure the port name doesn't already exist (I can probably use EnumPorts for this, but I'm not sure that's the best approach given that I have to also create ports)
- Create the port name if it does exist
- Change the printer configuration to use the new port
and for uninstall:
- Remove the port