ジョブ管理
重要
最新の印刷プラットフォームは、Windows がプリンターと通信するための推奨手段です。 プリンターデバイス開発におけるWindows 10および11での印刷体験をカスタマイズするために、MicrosoftのIPPインボックスクラスドライバーとPrint Support Apps (PSA)の使用を推奨します。
詳細については、「印刷サポート アプリの設計ガイド」を参照してください。
ジョブ キューのライブ ビューを提供するために、Windows 8.1 以降のバージョンの Windows でジョブ管理機能が導入されました。
この機能により、クライアントは印刷ジョブを取り消すこともできます。 クライアントは、UWP デバイス アプリ内またはプリンター拡張機能から適切なプログラミング インターフェイスを呼び出すことができます。
新しいインターフェイス
ジョブ管理機能を実装するために、Windows 8.1 では次のインターフェイスが導入されています。
ジョブ管理セッションの開始
ジョブ管理セッションを開始するには、まず管理するジョブの範囲を指定して要求する必要があります。 この範囲のジョブは "ビュー" と呼ばれ、 IPrinterQueue2::GetPrinterQueueView メソッドを使用して指定します。
ビューを変更して別のジョブ セットを監視する場合は、 IPrinterQueueView::SetViewRange メソッドを使用してこれを行うことができます。
印刷キューは動的キューであることに注意してください。 そのため、印刷キューの状態が変わるたびにイベントが発生し、 IPrinterQueueViewEvent::OnChanged メソッドは要求されたビューの更新されたスナップショットを提供します。
次の C# コード スニペットは、ジョブ管理セッションを開始するための新しいインターフェイスの使用を示しています。
void PerformJobManagement(IPrinterQueue2 queue)
{
//
// Create a printer queue view and specify the range of
// print queue positions to be monitored
//
PrinterQueueView queueView = queue.GetPrinterQueueView(0, COUNT_JOBS_MONITORED);
//
// Add the event handler to the IPrinterQueueView object via the
// standard COM event model, the IConnectionPoint mechanism.
//
queueView.OnChanged += queueView_OnChanged;
//
// When a different range of print jobs needs to be monitored,
// reset/update the view.
//
queueView.SetViewRange(20, COUNT_JOBS_MONITORED);
}
//
// Create an event handler that is called when
// there is a change in the View
//
void queueView_OnChanged(
IPrintJobCollection pcollection,
uint ulviewOffset,
uint ulviewSize,
uint ulcountJobsInPrintQueue)
{
foreach (IPrintJob job in pCollection)
{
UIDisplay(job.Name);
UIDisplay(job.Id);
}
}
UIDisplay は、ユーザーに情報を表示するために開発するメカニズムの一般的な名前を使用します。
また、ジョブの列挙は、最初のイベント ハンドラーが追加されたときに開始され、最後のイベント ハンドラーが削除されたときに停止されることに注意してください。