0
열전 사 프린터로 원시 데이터를 인쇄하려고하는데 인쇄 할 때마다 PInvokeStackImbalance
이 표시됩니다.원시 프린터에서 인쇄 할 수 없습니다.
인쇄하려면 this 예를 사용하고 있습니다. 그리고 예외는 항상 여기에서 발생합니다
Public Shared Function SendBytesToPrinter(ByVal szPrinterName As String, ByVal pBytes As IntPtr, ByVal dwCount As Int32) As Boolean
Dim hPrinter As IntPtr ' The printer handle.
Dim dwError As Int32 ' Last error - in case there was trouble.
Dim di As DOCINFOW ' Describes your document (name, port, data type).
Dim dwWritten As Int32 ' The number of bytes written by WritePrinter().
Dim bSuccess As Boolean ' Your success code.
' Set up the DOCINFO structure.
With di
.pDocName = "My Visual Basic .NET RAW Document"
.pDataType = "RAW"
End With
' Assume failure unless you specifically succeed.
bSuccess = False
If OpenPrinter(szPrinterName, hPrinter, 0) Then
If StartDocPrinter(hPrinter, 1, di) Then
If StartPagePrinter(hPrinter) Then
' Write your printer-specific bytes to the printer.
bSuccess = WritePrinter(hPrinter, pBytes, dwCount, dwWritten)
EndPagePrinter(hPrinter)
End If
EndDocPrinter(hPrinter)
End If
ClosePrinter(hPrinter)
End If
' If you did not succeed, GetLastError may give more information
' about why not.
If bSuccess = False Then
dwError = Marshal.GetLastWin32Error()
End If
Return bSuccess
End Function ' SendBytesToPrinter()
예외는이 라인 If OpenPrinter(szPrinterName, hPrinter, 0) Then
나는 몇 가지 조사를했다하지만 난 무슨 일이 일어나고 있는지 모르는에 있습니다. 어떤 도움이라도 좋을 것입니다. 미리 감사드립니다.