Страница: 1 |
|
Вопрос: Работа с процессами
|
Добавлено: 22.12.08 07:31
|
|
Автор вопроса: vbSerGanT
|
Привет. Может быть кто встречался с такими вопросами: Человек отправил какой нибудь файл на печать из какой нибудь программы. Надо отловить название файла, количество страниц, время и дату распечатки. И если это возможно скопировать файл в какую нибудь папку. Если файл находится в запороленном архиве попытаться его оттуда вынуть. Заранее спасибо...
Ответить
|
Номер ответа: 3 Автор ответа: Father
Вопросов: 0 Ответов: 159
|
Профиль | | #3
|
Добавлено: 22.12.08 15:34
|
Вот, накидал такую болванку на VBNET. Для начала - сойдет.
-
- Private Structure SYSTEMTIME
- Dim wYear As Short
- Dim wMonth As Short
- Dim wDayOfWeek As Short
- Dim wDay As Short
- Dim wHour As Short
- Dim wMinute As Short
- Dim wSecond As Short
- Dim wMilliseconds As Short
- End Structure
-
- Private Structure JOB_INFO_1
- Dim JobId As Integer
- Dim pPrinterName As Integer
- Dim pMachineName As Integer
- Dim pUserName As Integer
- Dim pDocument As Integer
- Dim pDatatype As Integer
- Dim pStatus As Integer
- Dim Status As Integer
- Dim Priority As Integer
- Dim Position As Integer
- Dim TotalPages As Integer
- Dim PagesPrinted As Integer
- Dim Submitted As SYSTEMTIME
- End Structure
-
- Private Structure JOB_INFO_2
- Public PrinterJobId As Integer
- Public pPrinterName As Integer
- Public PrinterName As Integer
- Public PrinterUserName As Integer
- Public PrinterDocument As Integer
- Public PrinterNotifyName As Integer
- Public PrinterDatatype As Integer
- Public PrintProcessor As Integer
- Public PrinterParameters As Integer
- Public PrinterDriverName As Integer
- Public PrinterDevMode As Integer
- Public PrinterStatus As Integer
- Public PrinterSecurityDescriptor As Integer
- Public pStatus As Integer
- Public PrinterPriority As Integer
- Public Position As Integer
- Public StartTime As Integer
- Public UntilTime As Integer
- Public TotalPages As Integer
- Public Size As Integer
- Public Submitted As SYSTEMTIME
- Public time As Integer
- Public PagesPrinted As Integer
- End Structure
-
-
- Private Declare Function EnumJobs Lib "winspool.drv" Alias "EnumJobsA" (ByVal hPrinter As IntPtr, ByVal FirstJob As Int32, ByVal NoJobs As Int32, ByVal Level As Int32, ByVal pJob As Byte(), ByVal cdBuf As Int32, ByRef pcbNeeded As Int32, ByRef pcReturned As Int32) As Long
- Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, ByRef phPrinter As IntPtr, ByVal pDefault As Int32) As Long
- Private Declare Function ClosePrinter Lib "winspool.drv" Alias "ClosePrinter" (ByVal hPrinter As IntPtr) As Long
- Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As JOB_INFO_1, ByVal Source() As Byte, ByVal Length As Int32)
-
-
- Private trd As New Threading.Thread(AddressOf trdproc)
- Private ext As Boolean = True
-
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- trd.Start()
- End Sub
- Private Sub Form1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Disposed
- ext = False
- End Sub
- Private Sub trdproc()
- Dim defprinter As String
- Do While ext
- defprinter = "Microsoft Office Document Image Writer"
- ListJobs(defprinter)
- trd.Sleep(10)
- Loop
- End Sub
-
-
-
-
- Private Function ListJobs(ByVal PrinterName As String) As Boolean
- Dim hPrinter As IntPtr
- Dim byteneed As Int32, count As Int32
- Dim pjobinfo() As Byte
- Dim jinfo1() As JOB_INFO_1
-
-
- If Not CBool(OpenPrinter(PrinterName, hPrinter, 0)) Then Return False
-
- If Not CBool(EnumJobs(hPrinter, 0, -1, 1, pjobinfo, 0, byteneed, count)) Then
- ClosePrinter(hPrinter)
- Return False
- End If
-
- If CBool(byteneed) Then
- ReDim pjobinfo(byteneed - 1)
- If Not CBool(EnumJobs(hPrinter, 0, -1, 1, pjobinfo, byteneed, byteneed, count)) Then
- ClosePrinter(hPrinter)
- Return False
- End If
-
- ReDim jinfo1(count - 1)
- Dim numbr As String
- Dim docnam As String
-
- For i As Integer = 0 To count - 1
- CopyMemory(jinfo1(i), pjobinfo, byteneed)
- numbr = jinfo1(i).JobId.ToString
- docnam = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(New IntPtr(jinfo1(i).pDocument))
-
- Next
- ClosePrinter(hPrinter)
- End If
-
- End Function
Ответить
|
Страница: 1 |
Поиск по форуму