共用方式為


HOW TO:診斷問題列印工作

網路系統管理員經常要處理使用者對列印工作的抱怨,如無法列印或列印得很慢。 Microsoft .NET Framework 的 APIs 中公開一組豐富的列印工作屬性 (Property),可用以執行列印工作的快速遠端診斷。

範例

建立這類公用程式的主要步驟如下。

  1. 識別使用者抱怨的列印工作。 使用者通常無法精確地做到這一點。 他們可能不知道列印伺服器或印表機的名稱。 他們會用不同的說法來描述印表機的位置,但不會說出印表機 Location 屬性 (Property) 的設定值。 因此,最好是產生一張使用者目前已送出工作的清單。 如果已送出的工作不止一個,使用者和列印系統管理員可以互相連絡以找出有問題的工作。 詳細步驟如下:

    1. 取得所有列印伺服器的清單。

    2. 在各伺服器之間執行迴圈 (Loop),查詢它們的列印佇列。

    3. 在伺服器迴圈的每一次傳遞中,在伺服器的所有佇列之間執行迴圈,查詢它們的工作。

    4. 在佇列迴圈的每一次傳遞中,在其工作之間執行迴圈,並收集抱怨的使用者送出的工作的識別資訊。

  2. 找出有問題的列印工作後,檢查相關的屬性 (Property),看看可能是什麼問題。 例如,工作是否在錯誤狀態之下?或處理這個佇列的印表機在列印工作開始前就離線了?

下列程式碼是一系列程式碼範例。 第一個程式碼範例是在列印佇列之間執行的迴圈 (上述的步驟 1c)。變數 myPrintQueues 是目前列印伺服器的 PrintQueueCollection 物件。

程式碼範例一開始先用 PrintQueue.Refresh 重新整理目前的列印佇列物件。 這可確保物件的屬性 (Property) 正確地表示它所代表的實體印表機的狀態。 然後應用程式使用 GetPrintJobInfoCollection 取得目前在列印佇列中的列印工作的集合。

接著應用程式在整個 PrintSystemJobInfo 集合中執行迴圈,比較每個 Submitter 屬性 (Property) 與抱怨使用者的別名。 如果相符,應用程式就會將這個工作的識別資訊加入即將顯示的字串中 (userName 和 jobList 變數稍早已在應用程式中初始化)。

                For Each pq As PrintQueue In myPrintQueues
                    pq.Refresh()
                    Dim jobs As PrintJobInfoCollection = pq.GetPrintJobInfoCollection()
                    For Each job As PrintSystemJobInfo In jobs
                        ' Since the user may not be able to articulate which job is problematic,
                        ' present information about each job the user has submitted.
                        If job.Submitter = userName Then
                            atLeastOne = True
                            jobList = jobList & vbLf & "Server:" & line
                            jobList = jobList & vbLf & vbTab & "Queue:" & pq.Name
                            jobList = jobList & vbLf & vbTab & "Location:" & pq.Location
                            jobList = jobList & vbLf & vbTab & vbTab & "Job: " & job.JobName & " ID: " & job.JobIdentifier
                        End If
                    Next job ' end for each print job

                Next pq ' end for each print queue
foreach (PrintQueue pq in myPrintQueues)
{
    pq.Refresh();
    PrintJobInfoCollection jobs = pq.GetPrintJobInfoCollection();
    foreach (PrintSystemJobInfo job in jobs)
    {
        // Since the user may not be able to articulate which job is problematic,
        // present information about each job the user has submitted.
        if (job.Submitter == userName)
        {
            atLeastOne = true;
            jobList = jobList + "\nServer:" + line;
            jobList = jobList + "\n\tQueue:" + pq.Name;
            jobList = jobList + "\n\tLocation:" + pq.Location;
            jobList = jobList + "\n\t\tJob: " + job.JobName + " ID: " + job.JobIdentifier;
        }
    }// end for each print job    

}// end for each print queue
for each (PrintQueue^ pq in myPrintQueues)
{
   pq->Refresh();
   PrintJobInfoCollection^ jobs = pq->GetPrintJobInfoCollection();
   for each (PrintSystemJobInfo^ job in jobs)
   {
      // Since the user may not be able to articulate which job is problematic,
      // present information about each job the user has submitted.
      if (job->Submitter == userName)
      {
         atLeastOne = true;
         jobList = jobList + "\nServer:" + line;
         jobList = jobList + "\n\tQueue:" + pq->Name;
         jobList = jobList + "\n\tLocation:" + pq->Location;
         jobList = jobList + "\n\t\tJob: " + job->JobName + " ID: " + job->JobIdentifier;
      }
   }
}

下一個程式碼範例會在步驟 2 挑選應用程式 (如上所述)。找出有問題的工作後,應用程式會提示您輸入可識別該工作的資訊。 它會從這些資訊建立 PrintServerPrintQueuePrintSystemJobInfo 物件。

此時的應用程式包含分支結構,與檢查列印工作狀態的兩種方式相對應:

這個範例示範了這兩種方法,因此使用者會在稍早收到要選擇哪個方法來使用的提示,並在要用 JobStatus 屬性 (Property) 的旗標時回應 "Y"。 請看以下對這兩種方法的詳細說明。 最後,應用程式使用 ReportQueueAndJobAvailability 方法報告這個工作是否可以在今天這個時刻進行列印。 這個方法在 HOW TO:得知列印工作是否可在此時列印中討論。

                ' When the problematic print job has been identified, enter information about it.
                Console.Write(vbLf & "Enter the print server hosting the job (including leading slashes \\): " & vbLf & "(press Return for the current computer \\{0}): ", Environment.MachineName)
                Dim pServer As String = Console.ReadLine()
                If pServer = "" Then
                    pServer = "\\" & Environment.MachineName
                End If
                Console.Write(vbLf & "Enter the print queue hosting the job: ")
                Dim pQueue As String = Console.ReadLine()
                Console.Write(vbLf & "Enter the job ID: ")
                Dim jobID As Int16 = Convert.ToInt16(Console.ReadLine())

                ' Create objects to represent the server, queue, and print job.
                Dim hostingServer As New PrintServer(pServer, PrintSystemDesiredAccess.AdministrateServer)
                Dim hostingQueue As New PrintQueue(hostingServer, pQueue, PrintSystemDesiredAccess.AdministratePrinter)
                Dim theJob As PrintSystemJobInfo = hostingQueue.GetJob(jobID)

                If useAttributesResponse = "Y" Then
                    TroubleSpotter.SpotTroubleUsingJobAttributes(theJob)
                    ' TroubleSpotter class is defined in the complete example.
                Else
                    TroubleSpotter.SpotTroubleUsingProperties(theJob)
                End If

                TroubleSpotter.ReportQueueAndJobAvailability(theJob)
// When the problematic print job has been identified, enter information about it.
Console.Write("\nEnter the print server hosting the job (including leading slashes \\\\): " +
"\n(press Return for the current computer \\\\{0}): ", Environment.MachineName);
String pServer = Console.ReadLine();
if (pServer == "")
{
    pServer = "\\\\" +Environment.MachineName;
}
Console.Write("\nEnter the print queue hosting the job: ");
String pQueue = Console.ReadLine(); 
Console.Write("\nEnter the job ID: ");
Int16 jobID = Convert.ToInt16(Console.ReadLine());

// Create objects to represent the server, queue, and print job.
PrintServer hostingServer = new PrintServer(pServer, PrintSystemDesiredAccess.AdministrateServer);
PrintQueue hostingQueue = new PrintQueue(hostingServer, pQueue, PrintSystemDesiredAccess.AdministratePrinter);
PrintSystemJobInfo theJob = hostingQueue.GetJob(jobID);

if (useAttributesResponse == "Y")
{
    TroubleSpotter.SpotTroubleUsingJobAttributes(theJob);
    // TroubleSpotter class is defined in the complete example.
}
else
{
    TroubleSpotter.SpotTroubleUsingProperties(theJob);
}

TroubleSpotter.ReportQueueAndJobAvailability(theJob);
// When the problematic print job has been identified, enter information about it.
Console::Write("\nEnter the print server hosting the job (including leading slashes \\\\): " + "\n(press Return for the current computer \\\\{0}): ", Environment::MachineName);
String^ pServer = Console::ReadLine();
if (pServer == "")
{
   pServer = "\\\\" + Environment::MachineName;
}
Console::Write("\nEnter the print queue hosting the job: ");
String^ pQueue = Console::ReadLine();
Console::Write("\nEnter the job ID: ");
Int16 jobID = Convert::ToInt16(Console::ReadLine());

// Create objects to represent the server, queue, and print job.
PrintServer^ hostingServer = gcnew PrintServer(pServer, PrintSystemDesiredAccess::AdministrateServer);
PrintQueue^ hostingQueue = gcnew PrintQueue(hostingServer, pQueue, PrintSystemDesiredAccess::AdministratePrinter);
PrintSystemJobInfo^ theJob = hostingQueue->GetJob(jobID);

if (useAttributesResponse == "Y")
{
   TroubleSpotter::SpotTroubleUsingJobAttributes(theJob);
   // TroubleSpotter class is defined in the complete example.
} else
{
   TroubleSpotter::SpotTroubleUsingProperties(theJob);
}

TroubleSpotter::ReportQueueAndJobAvailability(theJob);

若要用 JobStatus 屬性 (Property) 的旗標檢查列印工作狀態,請檢查每一個相關旗標,看它是否有設定。 若要查看一組位元旗標中是否設定位元,標準的做法是執行邏輯 AND 運算,以這組旗標做為一個運算元,旗標本身則做為另一個運算元。 因為旗標本身只設定一個位元,所以邏輯 AND 運算的結果最多會設定相同的位元。 若要找出是否已設定該位元,則只要比較邏輯 AND 的結果和旗標本身即可。 如需詳細資訊,請參閱 PrintJobStatus& 運算子 (C# 參考)FlagsAttribute

程式碼會將每一個有設定位元的屬性 (Attribute) 報告至主控台螢幕中,而且有時候會建議回應的方式 (如果工作或佇列已暫停,就會 HandlePausedJob 方法,稍後討論這個方法)。

        ' Check for possible trouble states of a print job using the flags of the JobStatus property
        Friend Shared Sub SpotTroubleUsingJobAttributes(ByVal theJob As PrintSystemJobInfo)
            If (theJob.JobStatus And PrintJobStatus.Blocked) = PrintJobStatus.Blocked Then
                Console.WriteLine("The job is blocked.")
            End If
            If ((theJob.JobStatus And PrintJobStatus.Completed) = PrintJobStatus.Completed) OrElse ((theJob.JobStatus And PrintJobStatus.Printed) = PrintJobStatus.Printed) Then
                Console.WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.")
            End If
            If ((theJob.JobStatus And PrintJobStatus.Deleted) = PrintJobStatus.Deleted) OrElse ((theJob.JobStatus And PrintJobStatus.Deleting) = PrintJobStatus.Deleting) Then
                Console.WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.")
            End If
            If (theJob.JobStatus And PrintJobStatus.Error) = PrintJobStatus.Error Then
                Console.WriteLine("The job has errored.")
            End If
            If (theJob.JobStatus And PrintJobStatus.Offline) = PrintJobStatus.Offline Then
                Console.WriteLine("The printer is offline. Have user put it online with printer front panel.")
            End If
            If (theJob.JobStatus And PrintJobStatus.PaperOut) = PrintJobStatus.PaperOut Then
                Console.WriteLine("The printer is out of paper of the size required by the job. Have user add paper.")
            End If

            If ((theJob.JobStatus And PrintJobStatus.Paused) = PrintJobStatus.Paused) OrElse ((theJob.HostingPrintQueue.QueueStatus And PrintQueueStatus.Paused) = PrintQueueStatus.Paused) Then
                HandlePausedJob(theJob)
                'HandlePausedJob is defined in the complete example.
            End If

            If (theJob.JobStatus And PrintJobStatus.Printing) = PrintJobStatus.Printing Then
                Console.WriteLine("The job is printing now.")
            End If
            If (theJob.JobStatus And PrintJobStatus.Spooling) = PrintJobStatus.Spooling Then
                Console.WriteLine("The job is spooling now.")
            End If
            If (theJob.JobStatus And PrintJobStatus.UserIntervention) = PrintJobStatus.UserIntervention Then
                Console.WriteLine("The printer needs human intervention.")
            End If

        End Sub 'end SpotTroubleUsingJobAttributes
// Check for possible trouble states of a print job using the flags of the JobStatus property
internal static void SpotTroubleUsingJobAttributes(PrintSystemJobInfo theJob)
{
    if ((theJob.JobStatus & PrintJobStatus.Blocked) == PrintJobStatus.Blocked)
    {
        Console.WriteLine("The job is blocked.");
    }
    if (((theJob.JobStatus & PrintJobStatus.Completed) == PrintJobStatus.Completed)
        || 
        ((theJob.JobStatus & PrintJobStatus.Printed) == PrintJobStatus.Printed))
    {
        Console.WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.");
    }
    if (((theJob.JobStatus & PrintJobStatus.Deleted) == PrintJobStatus.Deleted)
        || 
        ((theJob.JobStatus & PrintJobStatus.Deleting) == PrintJobStatus.Deleting))
    {
        Console.WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.");
    }
    if ((theJob.JobStatus & PrintJobStatus.Error) == PrintJobStatus.Error)
    {
        Console.WriteLine("The job has errored.");
    }
    if ((theJob.JobStatus & PrintJobStatus.Offline) == PrintJobStatus.Offline)
    {
        Console.WriteLine("The printer is offline. Have user put it online with printer front panel.");
    }
    if ((theJob.JobStatus & PrintJobStatus.PaperOut) == PrintJobStatus.PaperOut)
    {
        Console.WriteLine("The printer is out of paper of the size required by the job. Have user add paper.");
    }

    if (((theJob.JobStatus & PrintJobStatus.Paused) == PrintJobStatus.Paused)
        || 
        ((theJob.HostingPrintQueue.QueueStatus & PrintQueueStatus.Paused) == PrintQueueStatus.Paused))
    {
        HandlePausedJob(theJob);
        //HandlePausedJob is defined in the complete example.
    }

    if ((theJob.JobStatus & PrintJobStatus.Printing) == PrintJobStatus.Printing)
    {
        Console.WriteLine("The job is printing now.");
    }
    if ((theJob.JobStatus & PrintJobStatus.Spooling) == PrintJobStatus.Spooling)
    {
        Console.WriteLine("The job is spooling now.");
    }
    if ((theJob.JobStatus & PrintJobStatus.UserIntervention) == PrintJobStatus.UserIntervention)
    {
        Console.WriteLine("The printer needs human intervention.");
    }

}//end SpotTroubleUsingJobAttributes
// Check for possible trouble states of a print job using the flags of the JobStatus property
static void SpotTroubleUsingJobAttributes (PrintSystemJobInfo^ theJob) 
{
   if ((theJob->JobStatus & PrintJobStatus::Blocked) == PrintJobStatus::Blocked)
   {
      Console::WriteLine("The job is blocked.");
   }
   if (((theJob->JobStatus & PrintJobStatus::Completed) == PrintJobStatus::Completed)
      || 
      ((theJob->JobStatus & PrintJobStatus::Printed) == PrintJobStatus::Printed))
   {
      Console::WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.");
   }
   if (((theJob->JobStatus & PrintJobStatus::Deleted) == PrintJobStatus::Deleted)
      || 
      ((theJob->JobStatus & PrintJobStatus::Deleting) == PrintJobStatus::Deleting))
   {
      Console::WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.");
   }
   if ((theJob->JobStatus & PrintJobStatus::Error) == PrintJobStatus::Error)
   {
      Console::WriteLine("The job has errored.");
   }
   if ((theJob->JobStatus & PrintJobStatus::Offline) == PrintJobStatus::Offline)
   {
      Console::WriteLine("The printer is offline. Have user put it online with printer front panel.");
   }
   if ((theJob->JobStatus & PrintJobStatus::PaperOut) == PrintJobStatus::PaperOut)
   {
      Console::WriteLine("The printer is out of paper of the size required by the job. Have user add paper.");
   }
   if (((theJob->JobStatus & PrintJobStatus::Paused) == PrintJobStatus::Paused)
      || 
      ((theJob->HostingPrintQueue->QueueStatus & PrintQueueStatus::Paused) == PrintQueueStatus::Paused))
   {
      HandlePausedJob(theJob);
      //HandlePausedJob is defined in the complete example.
   }

   if ((theJob->JobStatus & PrintJobStatus::Printing) == PrintJobStatus::Printing)
   {
      Console::WriteLine("The job is printing now.");
   }
   if ((theJob->JobStatus & PrintJobStatus::Spooling) == PrintJobStatus::Spooling)
   {
      Console::WriteLine("The job is spooling now.");
   }
   if ((theJob->JobStatus & PrintJobStatus::UserIntervention) == PrintJobStatus::UserIntervention)
   {
      Console::WriteLine("The printer needs human intervention.");
   }
};

若要用個別的屬性 (Property) 檢查列印工作狀態,您只需要看每一個屬性,如果屬性為 true,就會報告至主控台螢幕中,而且可能會建議回應方式 (如果工作或佇列已暫停,就是 HandlePausedJob 方法,稍後討論此方法)。

        ' Check for possible trouble states of a print job using its properties
        Friend Shared Sub SpotTroubleUsingProperties(ByVal theJob As PrintSystemJobInfo)
            If theJob.IsBlocked Then
                Console.WriteLine("The job is blocked.")
            End If
            If theJob.IsCompleted OrElse theJob.IsPrinted Then
                Console.WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.")
            End If
            If theJob.IsDeleted OrElse theJob.IsDeleting Then
                Console.WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.")
            End If
            If theJob.IsInError Then
                Console.WriteLine("The job has errored.")
            End If
            If theJob.IsOffline Then
                Console.WriteLine("The printer is offline. Have user put it online with printer front panel.")
            End If
            If theJob.IsPaperOut Then
                Console.WriteLine("The printer is out of paper of the size required by the job. Have user add paper.")
            End If

            If theJob.IsPaused OrElse theJob.HostingPrintQueue.IsPaused Then
                HandlePausedJob(theJob)
                'HandlePausedJob is defined in the complete example.
            End If

            If theJob.IsPrinting Then
                Console.WriteLine("The job is printing now.")
            End If
            If theJob.IsSpooling Then
                Console.WriteLine("The job is spooling now.")
            End If
            If theJob.IsUserInterventionRequired Then
                Console.WriteLine("The printer needs human intervention.")
            End If

        End Sub 'end SpotTroubleUsingProperties
// Check for possible trouble states of a print job using its properties
internal static void SpotTroubleUsingProperties(PrintSystemJobInfo theJob)
{
    if (theJob.IsBlocked)
    {
        Console.WriteLine("The job is blocked.");
    }
    if (theJob.IsCompleted || theJob.IsPrinted)
    {
        Console.WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.");
    }
    if (theJob.IsDeleted || theJob.IsDeleting)
    {
        Console.WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.");
    }
    if (theJob.IsInError)
    {
        Console.WriteLine("The job has errored.");
    }
    if (theJob.IsOffline)
    {
        Console.WriteLine("The printer is offline. Have user put it online with printer front panel.");
    }
    if (theJob.IsPaperOut)
    {
        Console.WriteLine("The printer is out of paper of the size required by the job. Have user add paper.");
    }

    if (theJob.IsPaused || theJob.HostingPrintQueue.IsPaused)
    {
        HandlePausedJob(theJob);
        //HandlePausedJob is defined in the complete example.
    }

    if (theJob.IsPrinting)
    {
        Console.WriteLine("The job is printing now.");
    }
    if (theJob.IsSpooling)
    {
        Console.WriteLine("The job is spooling now.");
    }
    if (theJob.IsUserInterventionRequired)
    {
        Console.WriteLine("The printer needs human intervention.");
    }

}//end SpotTroubleUsingProperties
// Check for possible trouble states of a print job using its properties
static void SpotTroubleUsingProperties (PrintSystemJobInfo^ theJob) 
{
   if (theJob->IsBlocked)
   {
      Console::WriteLine("The job is blocked.");
   }
   if (theJob->IsCompleted || theJob->IsPrinted)
   {
      Console::WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.");
   }
   if (theJob->IsDeleted || theJob->IsDeleting)
   {
      Console::WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.");
   }
   if (theJob->IsInError)
   {
      Console::WriteLine("The job has errored.");
   }
   if (theJob->IsOffline)
   {
      Console::WriteLine("The printer is offline. Have user put it online with printer front panel.");
   }
   if (theJob->IsPaperOut)
   {
      Console::WriteLine("The printer is out of paper of the size required by the job. Have user add paper.");
   }

   if (theJob->IsPaused || theJob->HostingPrintQueue->IsPaused)
   {
      HandlePausedJob(theJob);
      //HandlePausedJob is defined in the complete example.
   }

   if (theJob->IsPrinting)
   {
      Console::WriteLine("The job is printing now.");
   }
   if (theJob->IsSpooling)
   {
      Console::WriteLine("The job is spooling now.");
   }
   if (theJob->IsUserInterventionRequired)
   {
      Console::WriteLine("The printer needs human intervention.");
   }
};

HandlePausedJob 方法讓應用程式的使用者可以從遠端恢復暫停的工作。 因為列印佇列暫停可能有個好理由,這個方法一開始會提示使用者決定是否要繼續工作。 如果答案是 "Y",就會呼叫 PrintQueue.Resume 方法。

接著會提示使用者決定工作本身是否應當繼續,以防萬一工作的暫停和列印佇列無關 (比較 PrintQueue.IsPausedPrintSystemJobInfo.IsPaused)。如果答案是 "Y",就會呼叫 PrintSystemJobInfo.Resume,若不是則呼叫 Cancel

        Friend Shared Sub HandlePausedJob(ByVal theJob As PrintSystemJobInfo)
            ' If there's no good reason for the queue to be paused, resume it and 
            ' give user choice to resume or cancel the job.
            Console.WriteLine("The user or someone with administrative rights to the queue" & vbLf & "has paused the job or queue." & vbLf & "Resume the queue? (Has no effect if queue is not paused.)" & vbLf & "Enter ""Y"" to resume, otherwise press return: ")
            Dim [resume] As String = Console.ReadLine()
            If [resume] = "Y" Then
                theJob.HostingPrintQueue.Resume()

                ' It is possible the job is also paused. Find out how the user wants to handle that.
                Console.WriteLine("Does user want to resume print job or cancel it?" & vbLf & "Enter ""Y"" to resume (any other key cancels the print job): ")
                Dim userDecision As String = Console.ReadLine()
                If userDecision = "Y" Then
                    theJob.Resume()
                Else
                    theJob.Cancel()
                End If
            End If 'end if the queue should be resumed

        End Sub 'end HandlePausedJob
internal static void HandlePausedJob(PrintSystemJobInfo theJob)
{
    // If there's no good reason for the queue to be paused, resume it and 
    // give user choice to resume or cancel the job.
    Console.WriteLine("The user or someone with administrative rights to the queue" +
         "\nhas paused the job or queue." +
         "\nResume the queue? (Has no effect if queue is not paused.)" +
         "\nEnter \"Y\" to resume, otherwise press return: ");
    String resume = Console.ReadLine();
    if (resume == "Y")
    {
        theJob.HostingPrintQueue.Resume();

        // It is possible the job is also paused. Find out how the user wants to handle that.
        Console.WriteLine("Does user want to resume print job or cancel it?" +
            "\nEnter \"Y\" to resume (any other key cancels the print job): ");
        String userDecision = Console.ReadLine();
        if (userDecision == "Y")
        {
            theJob.Resume();
        }
        else
        {
            theJob.Cancel();
        }
    }//end if the queue should be resumed

}//end HandlePausedJob
static void HandlePausedJob (PrintSystemJobInfo^ theJob) 
{
   // If there's no good reason for the queue to be paused, resume it and 
   // give user choice to resume or cancel the job.
   Console::WriteLine("The user or someone with administrative rights to the queue" + "\nhas paused the job or queue." + "\nResume the queue? (Has no effect if queue is not paused.)" + "\nEnter \"Y\" to resume, otherwise press return: ");
   String^ resume = Console::ReadLine();
   if (resume == "Y")
   {
      theJob->HostingPrintQueue->Resume();

      // It is possible the job is also paused. Find out how the user wants to handle that.
      Console::WriteLine("Does user want to resume print job or cancel it?" + "\nEnter \"Y\" to resume (any other key cancels the print job): ");
      String^ userDecision = Console::ReadLine();
      if (userDecision == "Y")
      {
         theJob->Resume();
      } else
      {
         theJob->Cancel();
      }
   }
};

請參閱

參考

PrintJobStatus

PrintSystemJobInfo

& 運算子 (C# 參考)

FlagsAttribute

PrintQueue

概念

WPF 中的文件

列印概觀