[DllImport("winspool.dll", SetLastError=true)]
static extern TODO StartDocPrinter(TODO);
Declare Function StartDocPrinter Lib "winspool.dll" (TODO) As TODO
<DllImport("winspool.drv", EntryPoint:="StartDocPrinterA", ExactSpelling:=True, SetLastError:=True, CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Ansi)> _
Private Shared Function StartDocPrinter(ByVal hPrinter As IntPtr, ByVal level As Integer, ByRef pDocInfo As DOC_INFO_1) As Integer
End Function
This implementation of StartDocPrinter must be used with the ANSI version of DOC_INFO_1.
Do you know one? Please contribute it!
StartDocPrinter returns a PrintJobIdentifier (integer value) and must not be declared Boolean!
According to MSDN the second parameter "level" must always be 1
Please add some!
Public Function StartDoc(hPrinter as IntPtr, ByVal documentTitle As String) As Boolean
Dim di As New DOC_INFO_1
With di
.pDocName = documentTitle
.pOutputFile = vbNullString
.pDatatype = vbNullString
End With
Dim printJobID as Integer = StartDocPrinter(hPrinter, 1, di)
Return (printJobID <> 0)
End Function