Horje
How to set a Printer Port in C# on a specified Printer Code Example
How to set a Printer Port in C# on a specified Printer
public static void SetPrinterPort(string printerName, string portName)
        {
            var oManagementScope = new ManagementScope(ManagementPath.DefaultPath);
            oManagementScope.Connect();

            SelectQuery oSelectQuery = new SelectQuery();
            oSelectQuery.QueryString = @"SELECT * FROM Win32_Printer 
            WHERE Name = '" + printerName.Replace("\\", "\\\\") + "'";

            ManagementObjectSearcher oObjectSearcher =
               new ManagementObjectSearcher(oManagementScope, @oSelectQuery);
            ManagementObjectCollection oObjectCollection = oObjectSearcher.Get();

            foreach (ManagementObject oItem in oObjectCollection)
            {
                oItem.Properties["PortName"].Value = portName;
                oItem.Put();
            }
        }




Csharp

Related
CS0120: An object reference is required for the non-static field, method, or property 'PlayerControls.currentState' Code Example CS0120: An object reference is required for the non-static field, method, or property 'PlayerControls.currentState' Code Example
summernote dropdown plugin Code Example summernote dropdown plugin Code Example
ASP.NET Core using of ValidationScriptsPartial Code Example ASP.NET Core using of ValidationScriptsPartial Code Example
vb.net check operating system Code Example vb.net check operating system Code Example
nunjucks index in loop Code Example nunjucks index in loop Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9