public void WinApiPrintByte(string p_PrintName, byte[] p_Byte) { if (p_PrintName != null && p_PrintName.Length > 0) { IntPtr _PrintHandle; IntPtr _JobHandle = Marshal.AllocHGlobal(2000); if (Win32API.OpenPrinter(p_PrintName, out _PrintHandle, IntPtr.Zero)) { ADDJOB_INFO_1 _JobInfo = new ADDJOB_INFO_1(); int _Size; Win32API.AddJob(_PrintHandle, 1, _JobHandle, 2000, out _Size); _JobInfo = (ADDJOB_INFO_1)Marshal.PtrToStructure(_JobHandle, typeof(ADDJOB_INFO_1)); //System.IO.File.WriteAllBytes(p_PrintName, p_Byte); System.IO.File.WriteAllBytes(_JobInfo.lpPath, p_Byte); Win32API.ScheduleJob(_PrintHandle, _JobInfo.JobID); Win32API.ClosePrinter(_PrintHandle); Marshal.FreeHGlobal(_JobHandle); } } }