NSDPrinterNotifyInfo メンバ
プリンターの通知情報。
●コンストラクタ
名前 説明 NSDPrinterNotifyInfo NSDPrinterNotifyInfoを初期化します。
●プロパティの一覧
名前 説明 Flag 通知フラグを返します。 JobInfoCollection ジョブ通知のリストを返します。 PrintInfoCollection プリンター通知のリストを返します。
●メソッドの一覧
名前 引数 戻り値 説明 Dispose なし なし NSDPrinterNotifyInfoクラスのオブジェクトで使用されている全てのリソースを解放します。
●NSDPrinterNotifyInfoコンストラクタの説明
構文:Public Sub New( Address )
使用法:Dim Cls_PrinterNotifyInfo As New NSDPrinterNotifyInfo(Address)
引数:
名前 型 引数渡しの方法 説明 Address IntPtr 参照渡し(ByRef) 通知情報のポインタを渡します。
※ポインタは関数内で解放し、IntPtr.Zeroを返します。使用例:なし。
●NSDPrinterNotifyInfoプロパティの説明
名前:Flag
構文:Public ReadOnly Property Flag() As Int32
機能:通知フラグを返します。
引数:なし。
値:Int32
値の説明:通知フラグを返します。
使用例:なし。
名前:JobInfoCollection
構文:Public ReadOnly Property JobInfoCollection() As NSDPrintJob()
機能:ジョブ通知のリストを返します。
引数:なし。
値の説明:ジョブ通知のリスト。
使用例:
Public Class Form1 Dim Cls_PWatch As NSDPrinterWatch = Nothing Private Sub Form1_FormClosed( sender As Object, _ e As System.Windows.Forms.FormClosedEventArgs _ ) Handles Me.FormClosed Cls_PWatch.Dispose() Cls_PWatch = Nothing End Sub Private Sub Form1_Load( sender As Object, _ e As System.EventArgs _ ) Handles Me.Load Cls_PWatch = New NSDPrinterWatch End Sub Private Sub Button1_Click( sender As System.Object, _ e As System.EventArgs _ ) Handles Button1.Click If Cls_PWatch.Watch Then ' 監視中. ' 監視を解除します. WatchEnd() Else ' 監視していない. Dim Int_General_Flags As NSDPrinterWatch.Printer_Change_Notification_General_Flags = _ NSDPrinterWatch.Printer_Change_Notification_General_Flags.PRINTER_CHANGE_ALL Dim Int_NotificationStyle As NSDPrinterWatch.NSD_NotificationStyle = _ NSDPrinterWatch.NSD_NotificationStyle.BOTH ' 監視を行います. If Cls_PWatch.PrinterWatch("監視するプリンタ名", Int_General_Flags, Int_NotificationStyle) Then ' 通知用イベントをセットします. AddHandler Cls_PWatch.Event_Change_Notification, AddressOf Change_Notification Else MsgBox("監視が正常に行えていません。") End If End If End Sub ' 監視を解除します. Private Sub WatchEnd() Cls_PWatch.PrinterWatchEnd() ' 通知用イベントを解除します. RemoveHandler Cls_PWatch.Event_Change_Notification, AddressOf Change_Notification End Sub Sub Change_Notification( ByVal Sender As NSDPrinterWatch, _ ByVal IntVal_General_Flag As NSDPrinterWatch.Printer_Change_Notification_General_Flags, _ ByVal IntVal_NotificationFlags As Integer, _ ByVal ClsNotifyInfo As NSDPrinterWatch.NSDPrinterNotifyInfo, _ ByVal Time As Date ) If IntVal_General_Flag = -1 AndAlso _ IntVal_NotificationFlags = -1 Then MsgBox("変更通知が受け取れないエラーが発生しました。") ' 監視中なので、監視を解除します. WatchEnd() Else Dim Str_DebugMsg As String = Nothing If Not ClsNotifyInfo.JobInfoCollection Is Nothing Then ' 印刷ジョブの通知情報が存在します. Dim Int_JobInfoCount As Integer = 1 For Each OneJob As NSDPrinterWatch.NSDPrintJob In ClsNotifyInfo.JobInfoCollection ' 一つの印刷ジョブ情報. Dim Str_JobMsg As String = Nothing Dim Str_JobInfoCount As String = "(" & Int_JobInfoCount.ToString & ")" Str_JobMsg = "印刷ジョブの名前" & Str_JobInfoCount & ":" & OneJob.DocumentName & ControlChars.CrLf Str_JobMsg &= "マシンの名前" & Str_JobInfoCount & ":" & OneJob.MachineName & ControlChars.CrLf Str_JobMsg &= "ユーザーの名前" & Str_JobInfoCount & ":" & OneJob.UserName & ControlChars.CrLf Str_DebugMsg &= Str_JobMsg Int_JobInfoCount += 1 Next Else Str_DebugMsg = "印刷ジョブの通知情報は、ありません。" End If Debug.WriteLine(Str_DebugMsg) End If End Sub End Class
名前:PrintInfoCollection
構文:Public ReadOnly Property PrintInfoCollection() As NSDPrintNotification()
機能:プリンター通知のリストを返します。
引数:なし。
値の説明:プリンター通知のリスト。
使用例:
Public Class Form1 Dim Cls_PWatch As NSDPrinterWatch = Nothing Private Sub Form1_FormClosed( sender As Object, _ e As System.Windows.Forms.FormClosedEventArgs _ ) Handles Me.FormClosed Cls_PWatch.Dispose() Cls_PWatch = Nothing End Sub Private Sub Form1_Load( sender As Object, _ e As System.EventArgs _ ) Handles Me.Load Cls_PWatch = New NSDPrinterWatch End Sub Private Sub Button1_Click( sender As System.Object, _ e As System.EventArgs _ ) Handles Button1.Click If Cls_PWatch.Watch Then ' 監視中. ' 監視を解除します. WatchEnd() Else ' 監視していない. Dim Int_General_Flags As NSDPrinterWatch.Printer_Change_Notification_General_Flags = _ NSDPrinterWatch.Printer_Change_Notification_General_Flags.PRINTER_CHANGE_ALL Dim Int_NotificationStyle As NSDPrinterWatch.NSD_NotificationStyle = _ NSDPrinterWatch.NSD_NotificationStyle.BOTH ' 監視を行います. If Cls_PWatch.PrinterWatch("監視するプリンタ名", Int_General_Flags, Int_NotificationStyle) Then ' 通知用イベントをセットします. AddHandler Cls_PWatch.Event_Change_Notification, AddressOf Change_Notification Else MsgBox("監視が正常に行えていません。") End If End If End Sub ' 監視を解除します. Private Sub WatchEnd() Cls_PWatch.PrinterWatchEnd() ' 通知用イベントを解除します. RemoveHandler Cls_PWatch.Event_Change_Notification, AddressOf Change_Notification End Sub Sub Change_Notification( ByVal Sender As NSDPrinterWatch, _ ByVal IntVal_General_Flag As NSDPrinterWatch.Printer_Change_Notification_General_Flags, _ ByVal IntVal_NotificationFlags As Integer, _ ByVal ClsNotifyInfo As NSDPrinterWatch.NSDPrinterNotifyInfo, _ ByVal Time As Date ) If IntVal_General_Flag = -1 AndAlso _ IntVal_NotificationFlags = -1 Then MsgBox("変更通知が受け取れないエラーが発生しました。") ' 監視中なので、監視を解除します. WatchEnd() Else Dim Str_DebugMsg As String = Nothing If Not ClsNotifyInfo.PrintInfoCollection Is Nothing Then ' プリンタ通知情報が存在します. Dim Int_PrintNotifyInfoCount As Integer = 1 For Each OnePrintNotify As NSDPrinterWatch.NSDPrintNotification In ClsNotifyInfo.PrintInfoCollection Dim Str_PrintNotifyMsg As String = Nothing Dim Str_PrintNotifyInfoCount As String = "(" & Int_PrintNotifyInfoCount.ToString & ")" Str_PrintNotifyMsg = "サーバーの名前" & Str_PrintNotifyInfoCount & ":" & OnePrintNotify.ServerName & ControlChars.CrLf Str_PrintNotifyMsg &= "プリンタの名前" & Str_PrintNotifyInfoCount & ":" & OnePrintNotify.PrinterName & ControlChars.CrLf Str_PrintNotifyMsg &= "出力ポートの名前" & Str_PrintNotifyInfoCount & ":" & OnePrintNotify.PortName & ControlChars.CrLf Str_DebugMsg &= Str_PrintNotifyMsg Int_PrintNotifyInfoCount += 1 Next End If Debug.WriteLine(Str_DebugMsg) End If End Sub End Class
●NSDPrinterNotifyInfoメソッドの説明
名前:Dispose
構文:Public Overridable Sub Dispose() 機能:NSDPrinterNotifyInfoクラスのオブジェクトで使用されている全てのリソースを解放します。
※終了時に必ず呼び出します。
引数:なし。
戻り値:なし。
使用例:なし。
Copyright (C) 2012 Nihon System Developer Corp. All Rights Reserved.