첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ LocalPrintServer 클래스의 InstallPrintQueue 메소드를 사용해 인쇄 큐를 복제하는 방법을 보여준다.

 

▶ 예제 코드 (C#)

using System;
using System.Printing;
using System.Printing.IndexedProperties;

LocalPrintServer localPrintServer = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer);

PrintQueue sourcePrintQueue = localPrintServer.DefaultPrintQueue;

PrintBooleanProperty isSharedPrintBooleanProperty = new PrintBooleanProperty("IsShared", true);
PrintStringProperty  shareNamePrintStringProperty = new PrintStringProperty("ShareName", $"\"Son of {sourcePrintQueue.Name}\"");
PrintStringProperty  locationPrintStringProperty  = new PrintStringProperty("Location", "the supply room");

PrintPropertyDictionary sourcePrintPropertyDictionary = sourcePrintQueue.PropertiesCollection;

sourcePrintPropertyDictionary.Remove("IsShared");

sourcePrintPropertyDictionary.Add("IsShared", isSharedPrintBooleanProperty);

sourcePrintPropertyDictionary.SetProperty("ShareName", shareNamePrintStringProperty);

sourcePrintPropertyDictionary.Remove("Location");

sourcePrintPropertyDictionary.Add("Location", locationPrintStringProperty);

string[] portArray = new string[] { "COM1:" };

PrintQueue targetPrintQueue = localPrintServer.InstallPrintQueue
(
    $"My clone of {sourcePrintQueue.Name}",
    "Xerox WCP 35 PS",
    portArray,
    "WinPrint",
    sourcePrintPropertyDictionary
);

localPrintServer.Commit();

Console.WriteLine("{0} in {1} has been installed and shared as {2}", targetPrintQueue.Name, targetPrintQueue.Location, targetPrintQueue.ShareName);

Console.WriteLine("Press Return to continue ...");

Console.ReadLine();
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요