直接输出字符串到远程打印机,出问题,贴代码,100分急求解!在线等
代码可以直接输出到远程打印机,但是A4纸上的却是乱码,代码如下,急求解,请高手指教!谢谢
public partial class Form1 : Form
{
public struct DOCINFO
{
[MarshalAs(UnmanagedType.LPWStr)]public string pDocName;
[MarshalAs(UnmanagedType.LPWStr)]public string pOutputFile;
[MarshalAs(UnmanagedType.LPWStr)]public string pDataType;
}
public class PrintDirect
{
[DllImport( "winspool.drv ", CharSet = CharSet.Unicode, ExactSpelling = false,
CallingConvention = CallingConvention.StdCall)]
public static extern long OpenPrinter(string pPrinterName, ref IntPtr phPrinter,
int pDefault);
[DllImport( "winspool.drv ", CharSet = CharSet.Unicode, ExactSpelling = false,
CallingConvention = CallingConvention.StdCall)]
public static extern long StartDocPrinter(IntPtr hPrinter, int Level,
ref DOCINFO pDocInfo);
[DllImport( "winspool.drv ", CharSet = CharSet.Unicode, ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]
public static extern long StartPagePrinter(IntPtr hPrinter);
[DllImport( "winspool.drv ", CharSet = CharSet.Ansi, ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]
public static extern long WritePrinter(IntPtr hPrinter, string data,
int buf, ref int pcWritten);
[DllImport( "winspool.drv ", CharSet = CharSet.Unicode, ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]