Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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();
            }
        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: unknown discriminator value mongodb 
Csharp :: unittest servicector automapper 
Csharp :: c# regex double of some letters only 
Csharp :: il c# 
Csharp :: 1180 - Lowest Number and Position C# 
Csharp :: Delegate no parameter no return 
Csharp :: Unity mousetoterrainposition 
Csharp :: c# message box carriage return 
Csharp :: collection to datatable c# 
Csharp :: c# nunit initialize variables 
Csharp :: c# move picturebox 
Csharp :: IAuthorizationFilter OnAuthorization AuthorizationContext MyAuthorizeAttribute HttpUnauthorizedResult HttpContext 
Csharp :: c# convert timestamp to datetime 
Csharp :: convert console app to linux 
Csharp :: c# get first and last day of current month 
Csharp :: querstring fromat asp.net c# 
Csharp :: isselected uicollectionview reused 
Csharp :: get all animation clip animator unity 
Csharp :: c# configurationmanager load from file 
Csharp :: google script get font color 
Csharp :: asp.net mvc class="" inline select 
Csharp :: unity sprite blurry when far 
Csharp :: how can find github issue closed date 
Csharp :: Unity search all chidren of parent object 
Csharp :: gersener waves 
Csharp :: nullable 
Csharp :: resize image and add watermark c# 
Csharp :: linq get values is not in other table 
Csharp :: switch case c# enum tostring 
Csharp :: use & symbole in xml as a text using c# 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =