VB转VB.NET打印问题
VB。NET中在CLASS中定义一个Private outFile As FileStreamPrivate hPortP As IntPtr Public Sub OpenPort(ByVal pPrinterPort As String) hPort = CreateFile(pPrinterPort, GENERIC_WRITE, FILE_SHARE_WRITE, SA, OPEN_EXISTING, 0, 0) hPortP = New IntPtr(hPort) outFile = New FileStream(hPortP, FileAccess.Write) End Sub Public Sub PrintLine(ByVal pLine As String) Dim fileWriter As New StreamWriter(outFile) fileWriter.Write(pLine) fileWriter.Flush() fileWriter.Close() End Sub Public Sub ClosePort() FileClose(iPort) outFile.Close() retval = CloseHandle(hPort) End Sub在程序中调用打印命令OpenPort("COM1")PrintLine("")PrintLine("ABC") '每次执行到这一步就出错。