Hi. I need help with creating a printer port programmatically in C#.
This is what I have
ManagementClass portClass = new ManagementClass("Win32_TCPIPPrinterPort");
ManagementObject portObject = portClass.CreateInstance();
portObject["Name"] = portName;
portObject["HostAddress"] = "174.30.164.15";
portObject["PortNumber"] = portNumber;
portObject["Protocol"] = 1;
portObject["SNMPCommunity"] = "public";
portObject["SNMPEnabled"] = true;
portObject["SNMPDevIndex"] = 1;
PutOptions options = new PutOptions();
options.Type = PutType.UpdateOrCreate;
portObject.Put(options);
This works fine, but it creates a TCP/IP printer port. I need to create a redirected printer port, a port type which is created by RedMon.
How do I create a port of any specified type? Is it possible to write a method of the form
void CreatePort(string portName,string portType)
which creates a port with the name portName and type portType, assuming that a port type with the name portType exists?
This is what I have
ManagementClass portClass = new ManagementClass("Win32_TCPIPPrinterPort");
ManagementObject portObject = portClass.CreateInstance();
portObject["Name"] = portName;
portObject["HostAddress"] = "174.30.164.15";
portObject["PortNumber"] = portNumber;
portObject["Protocol"] = 1;
portObject["SNMPCommunity"] = "public";
portObject["SNMPEnabled"] = true;
portObject["SNMPDevIndex"] = 1;
PutOptions options = new PutOptions();
options.Type = PutType.UpdateOrCreate;
portObject.Put(options);
This works fine, but it creates a TCP/IP printer port. I need to create a redirected printer port, a port type which is created by RedMon.
How do I create a port of any specified type? Is it possible to write a method of the form
void CreatePort(string portName,string portType)
which creates a port with the name portName and type portType, assuming that a port type with the name portType exists?