From ef7b93a3ac2a487a5f633d181f19e9e1052a1d5d Mon Sep 17 00:00:00 2001 From: jongwuner Date: Sat, 7 Dec 2019 17:02:08 +0900 Subject: [PATCH] first commit x64porting #29 commit print api --- 22hours_print_api/22hours_print_api.sln | 37 ++ .../22hours_print_api.csproj | 97 +++ .../22hours_print_api/App.config | 6 + .../22hours_print_api/Monitor.cs | 257 ++++++++ .../PrintJobChangeEventArgs.cs | 33 + .../22hours_print_api/PrintSpoolAPI.cs | 610 ++++++++++++++++++ .../22hours_print_api/Program.cs | 24 + .../Properties/AssemblyInfo.cs | 36 ++ 8 files changed, 1100 insertions(+) create mode 100644 22hours_print_api/22hours_print_api.sln create mode 100644 22hours_print_api/22hours_print_api/22hours_print_api.csproj create mode 100644 22hours_print_api/22hours_print_api/App.config create mode 100644 22hours_print_api/22hours_print_api/Monitor.cs create mode 100644 22hours_print_api/22hours_print_api/PrintJobChangeEventArgs.cs create mode 100644 22hours_print_api/22hours_print_api/PrintSpoolAPI.cs create mode 100644 22hours_print_api/22hours_print_api/Program.cs create mode 100644 22hours_print_api/22hours_print_api/Properties/AssemblyInfo.cs diff --git a/22hours_print_api/22hours_print_api.sln b/22hours_print_api/22hours_print_api.sln new file mode 100644 index 0000000..c4214d3 --- /dev/null +++ b/22hours_print_api/22hours_print_api.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.645 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "22hours_print_api", "22hours_print_api\22hours_print_api.csproj", "{45081B42-1428-47B3-88CE-974E4787337A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {45081B42-1428-47B3-88CE-974E4787337A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {45081B42-1428-47B3-88CE-974E4787337A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {45081B42-1428-47B3-88CE-974E4787337A}.Debug|x64.ActiveCfg = Debug|x64 + {45081B42-1428-47B3-88CE-974E4787337A}.Debug|x64.Build.0 = Debug|x64 + {45081B42-1428-47B3-88CE-974E4787337A}.Debug|x86.ActiveCfg = Debug|x86 + {45081B42-1428-47B3-88CE-974E4787337A}.Debug|x86.Build.0 = Debug|x86 + {45081B42-1428-47B3-88CE-974E4787337A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {45081B42-1428-47B3-88CE-974E4787337A}.Release|Any CPU.Build.0 = Release|Any CPU + {45081B42-1428-47B3-88CE-974E4787337A}.Release|x64.ActiveCfg = Release|Any CPU + {45081B42-1428-47B3-88CE-974E4787337A}.Release|x64.Build.0 = Release|Any CPU + {45081B42-1428-47B3-88CE-974E4787337A}.Release|x86.ActiveCfg = Release|x86 + {45081B42-1428-47B3-88CE-974E4787337A}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3B8995F2-11DD-4469-B650-1C34F251718B} + EndGlobalSection +EndGlobal diff --git a/22hours_print_api/22hours_print_api/22hours_print_api.csproj b/22hours_print_api/22hours_print_api/22hours_print_api.csproj new file mode 100644 index 0000000..806fa6f --- /dev/null +++ b/22hours_print_api/22hours_print_api/22hours_print_api.csproj @@ -0,0 +1,97 @@ + + + + + Debug + AnyCPU + {45081B42-1428-47B3-88CE-974E4787337A} + Exe + _22hours_print_api + 22hours_print_api + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/22hours_print_api/22hours_print_api/App.config b/22hours_print_api/22hours_print_api/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/22hours_print_api/22hours_print_api/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/22hours_print_api/22hours_print_api/Monitor.cs b/22hours_print_api/22hours_print_api/Monitor.cs new file mode 100644 index 0000000..d06fd89 --- /dev/null +++ b/22hours_print_api/22hours_print_api/Monitor.cs @@ -0,0 +1,257 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Printing; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using _22hours_print_api.SpoolAPI; + +namespace _22hours_print_api.Monitor +{ + class Monitor + { + #region Monitor private variables + private IntPtr _printerHandle = IntPtr.Zero; + private IntPtr _changeHandle = IntPtr.Zero; + private string _spoolerName = "Microsoft Print to PDF"; // 어떤 프린터던지 설정을 가져오는 것. + private ManualResetEvent _mrEvent = new ManualResetEvent(false); // 대기중인 thread에 하나이상의 이벤트가 발생했음을 알린다. + private RegisteredWaitHandle _waitHandle = null; // ??? + private PRINTER_NOTIFY_OPTIONS _notifyOptions = new PRINTER_NOTIFY_OPTIONS(); + private Dictionary objJobDict = new Dictionary(); + private PrintQueue _spooler = null; + #endregion + + #region PrinterDelegation + public delegate void PrintJobStatusChanged(object Sender, PrintJobChangeEventArgs e); + #endregion + + #region PrinterEvent + public event PrintJobStatusChanged OnJobStatusChange; + public void EventOccur(object Sender, PrintJobChangeEventArgs e) + { + Console.WriteLine("Print Event Occur!"); + } + #endregion + + #region DLL Import + // OpenPrinter : 프린터 생성 + [DllImport("winspool.drv", EntryPoint = "OpenPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + public static extern bool OpenPrinter(String pPrinterName, +out IntPtr phPrinter, +Int32 pDefault); + + [DllImport("winspool.drv", EntryPoint = "ClosePrinter", + SetLastError = true, + ExactSpelling = true, + CallingConvention = CallingConvention.StdCall)] + public static extern bool ClosePrinter +(Int32 hPrinter); + + // FindFirstPrinterChangeNotification : 첫번째 변화감지를 알린다. + [DllImport("winspool.drv", + EntryPoint = "FindFirstPrinterChangeNotification", + SetLastError = true, CharSet = CharSet.Ansi, + ExactSpelling = true, + CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr FindFirstPrinterChangeNotification + ([InAttribute()] IntPtr hPrinter, + [InAttribute()] Int32 fwFlags, + [InAttribute()] Int32 fwOptions, + [InAttribute(), MarshalAs(UnmanagedType.LPStruct)] PRINTER_NOTIFY_OPTIONS pPrinterNotifyOptions); + + // FindNextPrinterChangeNotification : 두번째 부터 ~ + [DllImport("winspool.drv", EntryPoint = "FindNextPrinterChangeNotification", +SetLastError = true, CharSet = CharSet.Ansi, +ExactSpelling = false, +CallingConvention = CallingConvention.StdCall)] + public static extern bool FindNextPrinterChangeNotification + ([InAttribute()] IntPtr hChangeObject, + [OutAttribute()] out Int32 pdwChange, + [InAttribute(), MarshalAs(UnmanagedType.LPStruct)] PRINTER_NOTIFY_OPTIONS pPrinterNotifyOptions, + [OutAttribute()] out IntPtr lppPrinterNotifyInfo); + + + // + [DllImport("winspool.drv", EntryPoint = "StartPagePrinter", +SetLastError = true, CharSet = CharSet.Ansi, +ExactSpelling = false, +CallingConvention = CallingConvention.StdCall)] + public static extern int StartPagePrinter + ([InAttribute()] IntPtr hPrinter); + #endregion + + #region MonitorConstructor + public Monitor() + { + OnPrinterWaiting(); + Start(); + } + #endregion + #region PrintStart + public void Start() + { + // out _printerHandle을 통해, 이름이 _spoolerName인 프린터의 제어권을 얻어온다. + OpenPrinter(_spoolerName, out _printerHandle, 0); + + if (_printerHandle != IntPtr.Zero) + { + //유효한 프린터 핸들을 등록한다. 변경감지 핸들을 생성하여 Printer or PrinterSever 변경사항을 감지할 수 있음. + // 1번째 인자 : OpenPrinter에서 반환한 Handle + // 2번째 인자 : ADD, WRITE, 등등 프린터에 JOB이 추가됬을 때, + // 3번째 인자 : 0일 때, 2D Printer + // 4번째 인자 : + _changeHandle = FindFirstPrinterChangeNotification(_printerHandle, (int)PRINTER_CHANGES.PRINTER_CHANGE_JOB, 0, _notifyOptions); + + // _mrEvent.Handle : 쓰레드에 1개이상의 이벤트가 발생했음을 알려준다. + _mrEvent.Handle = _changeHandle; + + //Now, let us wait for change notification from the printer queue.... + + // RegisterWaitForSingleObject + // 1번재 인자 : _mrEvent + // _mrEvent에 신호가 있으면, Interrupt를 걸어도 되겠다! + // _mrEvent에 신호가 없으면, 계속 대기 + // 2번째 인자 : WaitOrTimerCallback + // 계속 실행할 인자 + // 3번째 인자 : 다음 callback함수 얼마간격으로 호출할건지 : -1은 곧바로. + _waitHandle = ThreadPool.RegisterWaitForSingleObject(_mrEvent, new WaitOrTimerCallback(PrinterNotifyWaitCallback), _mrEvent, -1, true); + } + + _spooler = new PrintQueue(new PrintServer(), _spoolerName); + foreach (PrintSystemJobInfo psi in _spooler.GetPrintJobInfoCollection()) + { + objJobDict[psi.JobIdentifier] = psi.Name; + } + + } + #endregion + + #region PrintStop + public void Stop() + { + if (_printerHandle != IntPtr.Zero) + { + ClosePrinter((int)_printerHandle); + _printerHandle = IntPtr.Zero; + } + } + #endregion + + + + public void OnPrinterWaiting() + { + OnJobStatusChange += new PrintJobStatusChanged(EventOccur); + } + + #region Callback Function + public void PrinterNotifyWaitCallback(Object state, bool timedOut) + { + //Console.WriteLine("Callback 발동!!!!!"); + if (_printerHandle == IntPtr.Zero) return; + #region read notification details + _notifyOptions.Count = 1; + int pdwChange = 0; + IntPtr pNotifyInfo = IntPtr.Zero; + bool bResult = FindNextPrinterChangeNotification(_changeHandle, out pdwChange, _notifyOptions, out pNotifyInfo); + + Console.WriteLine("pdwChange : {0} / pNotifiyInfo : {1}", pdwChange, pNotifyInfo); + //If the Printer Change Notification Call did not give data, exit code + if ((bResult == false) || ((pNotifyInfo.ToInt64()) == 0)) return; + + //If the Change Notification was not relgated to job, exit code + //Job이 ADDJOB, 이딴게 맞는지 한번 보는 것!! + bool bJobRelatedChange = ((pdwChange & PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB) == PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB) || + ((pdwChange & PRINTER_CHANGES.PRINTER_CHANGE_SET_JOB) == PRINTER_CHANGES.PRINTER_CHANGE_SET_JOB) || + ((pdwChange & PRINTER_CHANGES.PRINTER_CHANGE_DELETE_JOB) == PRINTER_CHANGES.PRINTER_CHANGE_DELETE_JOB) || + ((pdwChange & PRINTER_CHANGES.PRINTER_CHANGE_WRITE_JOB) == PRINTER_CHANGES.PRINTER_CHANGE_WRITE_JOB); + if (!bJobRelatedChange) return; + #endregion + + #region Interrupt Catch!!!!!! + if(bJobRelatedChange == ((pdwChange & PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB) == PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB)){ + Console.WriteLine("☆☆☆☆☆☆☆☆ Login Auth ☆☆☆☆☆☆☆☆"); + // if(로그인 여부 -> Login 성공 -> CB) 프린터 계속 진행. + // if(종료) 함수종료. + + } + #endregion + + + #region populate Notification Information + //Now, let us initialize and populate the Notify Info data + PRINTER_NOTIFY_INFO info = (PRINTER_NOTIFY_INFO)Marshal.PtrToStructure(pNotifyInfo, typeof(PRINTER_NOTIFY_INFO)); + Int64 pData = pNotifyInfo.ToInt64() + Marshal.SizeOf(typeof(PRINTER_NOTIFY_INFO)); + PRINTER_NOTIFY_INFO_DATA[] data = new PRINTER_NOTIFY_INFO_DATA[info.Count]; + for (uint i = 0; i < info.Count; i++) + { + data[i] = (PRINTER_NOTIFY_INFO_DATA)Marshal.PtrToStructure((IntPtr)pData, typeof(PRINTER_NOTIFY_INFO_DATA)); + pData += Marshal.SizeOf(typeof(PRINTER_NOTIFY_INFO_DATA)); + } + #endregion + + #region iterate through all elements in the data array + for (int i = 0; i < data.Count(); i++) + { + + if ((data[i].Field == (ushort)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_STATUS) && + (data[i].Type == (ushort)PRINTERNOTIFICATIONTYPES.JOB_NOTIFY_TYPE) + ) + { + JOBSTATUS jStatus = (JOBSTATUS)Enum.Parse(typeof(JOBSTATUS), data[i].NotifyData.Data.cbBuf.ToString()); + int intJobID = (int)data[i].Id; + string strJobName = ""; + PrintSystemJobInfo pji = null; + try + { + _spooler = new PrintQueue(new PrintServer(), _spoolerName); + pji = _spooler.GetJob(intJobID); + if (!objJobDict.ContainsKey(intJobID)) + objJobDict[intJobID] = pji.Name; + strJobName = pji.Name; + + if (bJobRelatedChange == ((pdwChange & PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB) == PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB)) + { + Console.WriteLine("★★★★★★★★ Print Out [First] ★★★★★★★★"); + // Print 시작 ~ 종료까지 Thread 대기 걸고. + // Print Real Page Count 넣어야 한다. + pji.Cancel(); + } + Console.WriteLine("삭제"); + pji.Cancel(); + } + catch + { + pji = null; + objJobDict.TryGetValue(intJobID, out strJobName); + if (strJobName == null) strJobName = ""; + } + + if (OnJobStatusChange != null) + { + //Let us raise the event + OnJobStatusChange(this, new PrintJobChangeEventArgs(intJobID, strJobName, jStatus, pji)); + + + } + } + } + #endregion + if (bJobRelatedChange == ((pdwChange & PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB) == PRINTER_CHANGES.PRINTER_CHANGE_ADD_JOB)) + { + Console.WriteLine("★★★★★★★★ Print Out [Second] ★★★★★★★★"); + // Print 시작 ~ 종료까지 Thread 대기 걸고. + // Print Real Page Count 넣어야 한다. + } + + #region reset the Event and wait for the next event + _mrEvent.Reset(); + _waitHandle = ThreadPool.RegisterWaitForSingleObject(_mrEvent, new WaitOrTimerCallback(PrinterNotifyWaitCallback), _mrEvent, -1, true); + #endregion + } + #endregion + + } +} diff --git a/22hours_print_api/22hours_print_api/PrintJobChangeEventArgs.cs b/22hours_print_api/22hours_print_api/PrintJobChangeEventArgs.cs new file mode 100644 index 0000000..f9117c7 --- /dev/null +++ b/22hours_print_api/22hours_print_api/PrintJobChangeEventArgs.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Printing; +using _22hours_print_api.SpoolAPI; + +namespace _22hours_print_api.Monitor +{ + public class PrintJobChangeEventArgs : EventArgs + { + #region private variables + private int _jobID = 0; + private string _jobName = ""; + private JOBSTATUS _jobStatus = new JOBSTATUS(); + private PrintSystemJobInfo _jobInfo = null; + #endregion + + public int JobID { get { return _jobID; } } + public string JobName { get { return _jobName; } } + public JOBSTATUS JobStatus { get { return _jobStatus; } } + public PrintSystemJobInfo JobInfo { get { return _jobInfo; } } + public PrintJobChangeEventArgs(int intJobID, string strJobName, JOBSTATUS jStatus, PrintSystemJobInfo objJobInfo) + : base() + { + _jobID = intJobID; + _jobName = strJobName; + _jobStatus = jStatus; + _jobInfo = objJobInfo; + } + } +} diff --git a/22hours_print_api/22hours_print_api/PrintSpoolAPI.cs b/22hours_print_api/22hours_print_api/PrintSpoolAPI.cs new file mode 100644 index 0000000..18dcadb --- /dev/null +++ b/22hours_print_api/22hours_print_api/PrintSpoolAPI.cs @@ -0,0 +1,610 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Runtime.InteropServices; +using System.Globalization; +using _22hours_print_api.Monitor; + +namespace _22hours_print_api.SpoolAPI +{ + public enum JOBCONTROL + { + JOB_CONTROL_PAUSE = 1, + JOB_CONTROL_RESUME = 2, + JOB_CONTROL_CANCEL = 3, + JOB_CONTROL_RESTART = 4, + JOB_CONTROL_DELETE = 5, + JOB_CONTROL_SENT_TO_PRINTER = 6, + JOB_CONTROL_LAST_PAGE_EJECTED = 7, + JOB_CONTROL_RETAIN = 8, + JOB_CONTROL_RELEASE = 9, + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public struct DEVMODE + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] + public string dmDeviceName; + + public short dmSpecVersion; + public short dmDriverVersion; + public short dmSize; + public short dmDriverExtra; + public int dmFields; + public int dmPositionX; + public int dmPositionY; + public int dmDisplayOrientation; + public int dmDisplayFixedOutput; + public short dmColor; + public short dmDuplex; + public short dmYResolution; + public short dmTTOption; + public short dmCollate; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] + public string dmFormName; + + public short dmLogPixels; + public short dmBitsPerPel; + public int dmPelsWidth; + public int dmPelsHeight; + public int dmDisplayFlags; + public int dmDisplayFrequency; + public int dmICMMethod; + public int dmICMIntent; + public int dmMediaType; + public int dmDitherType; + public int dmReserved1; + public int dmReserved2; + public int dmPanningWidth; + public int dmPanningHeight; + + public override string ToString() + { + return string.Format( + @"dmDeviceName == '{0}', +dmSpecVersion == {1}, +dmDriverVersion == {2}, +dmSize == {3}, +dmDriverExtra == {4}, +dmFields == {5}, +dmPositionX == {6}, +dmPositionY == {7}, +dmDisplayOrientation == {8}, +dmDisplayFixedOutput == {9}, +dmColor == {10}, +dmDuplex == {11}, +dmYResolution == {12}, +dmTTOption == {13}, +dmCollate == {14}, +dmFormName == {15}, +dmLogPixels == {16}, +dmBitsPerPel == {17}, +dmPelsWidth == {18}, +dmPelsHeight == {19}, +dmDisplayFlags == {20}, +dmDisplayFrequency == {21}, +dmICMMethod == {22}, +dmICMIntent == {23}, +dmMediaType == {24}, +dmPanningWidth == {25}, +dmPanningHeight == {26}", + dmDeviceName, + dmSpecVersion, + dmDriverVersion, + dmSize, + dmDriverExtra, + dmFields, + dmPositionX, + dmPositionY, + dmDisplayOrientation, + dmDisplayFixedOutput, + dmColor, + dmDuplex, + dmYResolution, + dmTTOption, + dmCollate, + dmFormName, + dmLogPixels, + dmBitsPerPel, + dmPelsWidth, + dmPelsHeight, + dmDisplayFlags, + dmDisplayFrequency, + dmICMMethod, + dmICMIntent, + dmMediaType, + dmPanningWidth, + dmPanningHeight); + + } + } + + [StructLayout(LayoutKind.Sequential)] + public struct SYSTEMTIME + { + [MarshalAs(UnmanagedType.U2)] + public short Year; + [MarshalAs(UnmanagedType.U2)] + public short Month; + [MarshalAs(UnmanagedType.U2)] + public short DayOfWeek; + [MarshalAs(UnmanagedType.U2)] + public short Day; + [MarshalAs(UnmanagedType.U2)] + public short Hour; + [MarshalAs(UnmanagedType.U2)] + public short Minute; + [MarshalAs(UnmanagedType.U2)] + public short Second; + [MarshalAs(UnmanagedType.U2)] + public short Milliseconds; + + public SYSTEMTIME(DateTime dt) + { + dt = dt.ToUniversalTime(); // SetSystemTime expects the SYSTEMTIME in UTC + Year = (short)dt.Year; + Month = (short)dt.Month; + DayOfWeek = (short)dt.DayOfWeek; + Day = (short)dt.Day; + Hour = (short)dt.Hour; + Minute = (short)dt.Minute; + Second = (short)dt.Second; + Milliseconds = (short)dt.Millisecond; + } + + public DateTime ToDateTime() + { + return new DateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds, CultureInfo.CurrentCulture.Calendar, DateTimeKind.Utc).ToLocalTime(); + } + } + + [Flags] + public enum JOBSTATUS + { + JOB_STATUS_PAUSED = 0x00000001, + JOB_STATUS_ERROR = 0x00000002, + JOB_STATUS_DELETING = 0x00000004, + JOB_STATUS_SPOOLING = 0x00000008, + JOB_STATUS_PRINTING = 0x00000010, + JOB_STATUS_OFFLINE = 0x00000020, + JOB_STATUS_PAPEROUT = 0x00000040, + JOB_STATUS_PRINTED = 0x00000080, + JOB_STATUS_DELETED = 0x00000100, + JOB_STATUS_BLOCKED_DEVQ = 0x00000200, + JOB_STATUS_USER_INTERVENTION = 0x00000400, + JOB_STATUS_RESTART = 0x00000800, + JOB_STATUS_COMPLETE = 0x00001000, + JOB_STATUS_RETAINED = 0x00002000, + JOB_STATUS_RENDERING_LOCALLY = 0x00004000, + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct PRINTER_INFO_2 + { + [MarshalAs(UnmanagedType.LPTStr)] + public string pServerName; + [MarshalAs(UnmanagedType.LPTStr)] + public string pPrinterName; + [MarshalAs(UnmanagedType.LPTStr)] + public string pShareName; + [MarshalAs(UnmanagedType.LPTStr)] + public string pPortName; + [MarshalAs(UnmanagedType.LPTStr)] + public string pDriverName; + [MarshalAs(UnmanagedType.LPTStr)] + public string pComment; + [MarshalAs(UnmanagedType.LPTStr)] + public string pLocation; + public IntPtr pDevMode; + [MarshalAs(UnmanagedType.LPTStr)] + public string pSepFile; + [MarshalAs(UnmanagedType.LPTStr)] + public string pPrintProcessor; + [MarshalAs(UnmanagedType.LPTStr)] + public string pDatatype; + [MarshalAs(UnmanagedType.LPTStr)] + public string pParameters; + public IntPtr pSecurityDescriptor; + public uint Attributes; + public uint Priority; + public uint DefaultPriority; + public uint StartTime; + public uint UntilTime; + public uint Status; + public uint cJobs; + public uint AveragePPM; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct JOB_INFO_1 + { + public UInt32 JobId; + public string pPrinterName; + public string pMachineName; + public string pUserName; + public string pDocument; + public string pDatatype; + public string pStatus; + public UInt32 Status; + public UInt32 Priority; + public UInt32 Position; + public UInt32 TotalPages; + public UInt32 PagesPrinted; + public SYSTEMTIME Submitted; + } + + public struct JOBINFO + { + + public int JobId; + + [MarshalAs(UnmanagedType.LPTStr)] + public string pPrinterName; + + [MarshalAs(UnmanagedType.LPTStr)] + public string pMachineName; + + [MarshalAs(UnmanagedType.LPTStr)] + public string pUserName; + + [MarshalAs(UnmanagedType.LPTStr)] + public string pDocument; + + [MarshalAs(UnmanagedType.LPTStr)] + public string pDatatype; + + [MarshalAs(UnmanagedType.LPTStr)] + public string pStatus; + + public int Status; + + public int Priority; + + public int Position; + + public int TotalPages; + + public int PagesPrinted; + + public SYSTEMTIME Submitted; + + } + + + [Flags] + public enum PRINTERATTRIBUTES + { + QUEUED = 1, + DIRECT = 2, + DEFAULT = 4, + SHARED = 8, + NETWORK = 0x10, + HIDDEN = 0x20, + LOCAL = 0x40, + ENABLE_DEVQ = 0x80, + KEEPPRINTEDJOBS = 0x100, + DO_COMPLETE_FIRST = 0x200, + WORK_OFFLINE = 0x400, + ENABLE_BIDI = 0x800, + RAW_ONLY = 0x1000, + PUBLISHED = 0x2000, + } + + [Flags] + public enum PRINTERSTATUS + { + PRINTER_STATUS_PAUSED = 1, + PRINTER_STATUS_ERROR = 2, + PRINTER_STATUS_PENDING_DELETION = 4, + PRINTER_STATUS_PAPER_JAM = 8, + PRINTER_STATUS_PAPER_OUT = 0x10, + PRINTER_STATUS_MANUAL_FEED = 0x20, + PRINTER_STATUS_PAPER_PROBLEM = 0x40, + PRINTER_STATUS_OFFLINE = 0x80, + PRINTER_STATUS_IO_ACTIVE = 0x100, + PRINTER_STATUS_BUSY = 0x200, + PRINTER_STATUS_PRINTING = 0x400, + PRINTER_STATUS_OUTPUT_BIN_FULL = 0x800, + PRINTER_STATUS_NOT_AVAILABLE = 0x1000, + PRINTER_STATUS_WAITING = 0x2000, + PRINTER_STATUS_PROCESSING = 0x4000, + PRINTER_STATUS_INITIALIZING = 0x8000, + PRINTER_STATUS_WARMING_UP = 0x10000, + PRINTER_STATUS_TONER_LOW = 0x20000, + PRINTER_STATUS_NO_TONER = 0x40000, + PRINTER_STATUS_PAGE_PUNT = 0x80000, + PRINTER_STATUS_USER_INTERVENTION = 0x100000, + PRINTER_STATUS_OUT_OF_MEMORY = 0x200000, + PRINTER_STATUS_DOOR_OPEN = 0x400000, + PRINTER_STATUS_SERVER_UNKNOWN = 0x800000, + PRINTER_STATUS_POWER_SAVE = 0x1000000, + } + + [FlagsAttribute] + public enum PrinterEnumFlags + { + PRINTER_ENUM_DEFAULT = 0x00000001, + PRINTER_ENUM_LOCAL = 0x00000002, + PRINTER_ENUM_CONNECTIONS = 0x00000004, + PRINTER_ENUM_FAVORITE = 0x00000004, + PRINTER_ENUM_NAME = 0x00000008, + PRINTER_ENUM_REMOTE = 0x00000010, + PRINTER_ENUM_SHARED = 0x00000020, + PRINTER_ENUM_NETWORK = 0x00000040, + PRINTER_ENUM_EXPAND = 0x00004000, + PRINTER_ENUM_CONTAINER = 0x00008000, + PRINTER_ENUM_ICONMASK = 0x00ff0000, + PRINTER_ENUM_ICON1 = 0x00010000, + PRINTER_ENUM_ICON2 = 0x00020000, + PRINTER_ENUM_ICON3 = 0x00040000, + PRINTER_ENUM_ICON4 = 0x00080000, + PRINTER_ENUM_ICON5 = 0x00100000, + PRINTER_ENUM_ICON6 = 0x00200000, + PRINTER_ENUM_ICON7 = 0x00400000, + PRINTER_ENUM_ICON8 = 0x00800000, + PRINTER_ENUM_HIDE = 0x01000000 + } + + public class PRINTER_CHANGES + { + public const uint PRINTER_CHANGE_ADD_PRINTER = 1; + public const uint PRINTER_CHANGE_SET_PRINTER = 2; + public const uint PRINTER_CHANGE_DELETE_PRINTER = 4; + public const uint PRINTER_CHANGE_FAILED_CONNECTION_PRINTER = 8; + public const uint PRINTER_CHANGE_PRINTER = 0xFF; + public const uint PRINTER_CHANGE_ADD_JOB = 0x100; + public const uint PRINTER_CHANGE_SET_JOB = 0x200; + public const uint PRINTER_CHANGE_DELETE_JOB = 0x400; + public const uint PRINTER_CHANGE_WRITE_JOB = 0x800; + public const uint PRINTER_CHANGE_JOB = 0xFF00; + public const uint PRINTER_CHANGE_ADD_FORM = 0x10000; + public const uint PRINTER_CHANGE_SET_FORM = 0x20000; + public const uint PRINTER_CHANGE_DELETE_FORM = 0x40000; + public const uint PRINTER_CHANGE_FORM = 0x70000; + public const uint PRINTER_CHANGE_ADD_PORT = 0x100000; + public const uint PRINTER_CHANGE_CONFIGURE_PORT = 0x200000; + public const uint PRINTER_CHANGE_DELETE_PORT = 0x400000; + public const uint PRINTER_CHANGE_PORT = 0x700000; + public const uint PRINTER_CHANGE_ADD_PRINT_PROCESSOR = 0x1000000; + public const uint PRINTER_CHANGE_DELETE_PRINT_PROCESSOR = 0x4000000; + public const uint PRINTER_CHANGE_PRINT_PROCESSOR = 0x7000000; + public const uint PRINTER_CHANGE_ADD_PRINTER_DRIVER = 0x10000000; + public const uint PRINTER_CHANGE_SET_PRINTER_DRIVER = 0x20000000; + public const uint PRINTER_CHANGE_DELETE_PRINTER_DRIVER = 0x40000000; + public const uint PRINTER_CHANGE_PRINTER_DRIVER = 0x70000000; + public const uint PRINTER_CHANGE_TIMEOUT = 0x80000000; + public const uint PRINTER_CHANGE_ALL = 0x7777FFFF; + } + + public enum PRINTERPRINTERNOTIFICATIONTYPES + { + PRINTER_NOTIFY_FIELD_SERVER_NAME = 0, + PRINTER_NOTIFY_FIELD_PRINTER_NAME = 1, + PRINTER_NOTIFY_FIELD_SHARE_NAME = 2, + PRINTER_NOTIFY_FIELD_PORT_NAME = 3, + PRINTER_NOTIFY_FIELD_DRIVER_NAME = 4, + PRINTER_NOTIFY_FIELD_COMMENT = 5, + PRINTER_NOTIFY_FIELD_LOCATION = 6, + PRINTER_NOTIFY_FIELD_DEVMODE = 7, + PRINTER_NOTIFY_FIELD_SEPFILE = 8, + PRINTER_NOTIFY_FIELD_PRINT_PROCESSOR = 9, + PRINTER_NOTIFY_FIELD_PARAMETERS = 10, + PRINTER_NOTIFY_FIELD_DATATYPE = 11, + PRINTER_NOTIFY_FIELD_SECURITY_DESCRIPTOR = 12, + PRINTER_NOTIFY_FIELD_ATTRIBUTES = 13, + PRINTER_NOTIFY_FIELD_PRIORITY = 14, + PRINTER_NOTIFY_FIELD_DEFAULT_PRIORITY = 15, + PRINTER_NOTIFY_FIELD_START_TIME = 16, + PRINTER_NOTIFY_FIELD_UNTIL_TIME = 17, + PRINTER_NOTIFY_FIELD_STATUS = 18, + PRINTER_NOTIFY_FIELD_STATUS_STRING = 19, + PRINTER_NOTIFY_FIELD_CJOBS = 20, + PRINTER_NOTIFY_FIELD_AVERAGE_PPM = 21, + PRINTER_NOTIFY_FIELD_TOTAL_PAGES = 22, + PRINTER_NOTIFY_FIELD_PAGES_PRINTED = 23, + PRINTER_NOTIFY_FIELD_TOTAL_BYTES = 24, + PRINTER_NOTIFY_FIELD_BYTES_PRINTED = 25, + } + + public enum PRINTERJOBNOTIFICATIONTYPES + { + JOB_NOTIFY_FIELD_PRINTER_NAME = 0, + JOB_NOTIFY_FIELD_MACHINE_NAME = 1, + JOB_NOTIFY_FIELD_PORT_NAME = 2, + JOB_NOTIFY_FIELD_USER_NAME = 3, + JOB_NOTIFY_FIELD_NOTIFY_NAME = 4, + JOB_NOTIFY_FIELD_DATATYPE = 5, + JOB_NOTIFY_FIELD_PRINT_PROCESSOR = 6, + JOB_NOTIFY_FIELD_PARAMETERS = 7, + JOB_NOTIFY_FIELD_DRIVER_NAME = 8, + JOB_NOTIFY_FIELD_DEVMODE = 9, + JOB_NOTIFY_FIELD_STATUS = 10, + JOB_NOTIFY_FIELD_STATUS_STRING = 11, + JOB_NOTIFY_FIELD_SECURITY_DESCRIPTOR = 12, + JOB_NOTIFY_FIELD_DOCUMENT = 13, + JOB_NOTIFY_FIELD_PRIORITY = 14, + JOB_NOTIFY_FIELD_POSITION = 15, + JOB_NOTIFY_FIELD_SUBMITTED = 16, + JOB_NOTIFY_FIELD_START_TIME = 17, + JOB_NOTIFY_FIELD_UNTIL_TIME = 18, + JOB_NOTIFY_FIELD_TIME = 19, + JOB_NOTIFY_FIELD_TOTAL_PAGES = 20, + JOB_NOTIFY_FIELD_PAGES_PRINTED = 21, + JOB_NOTIFY_FIELD_TOTAL_BYTES = 22, + JOB_NOTIFY_FIELD_BYTES_PRINTED = 23, + } + + [StructLayout(LayoutKind.Sequential)] + public class PRINTER_NOTIFY_OPTIONS + { + public int dwVersion = 2; + public int dwFlags; + public int Count = 2; + public IntPtr lpTypes; + + public PRINTER_NOTIFY_OPTIONS() + { + int bytesNeeded = (2 + PRINTER_NOTIFY_OPTIONS_TYPE.JOB_FIELDS_COUNT + PRINTER_NOTIFY_OPTIONS_TYPE.PRINTER_FIELDS_COUNT) * 2; + PRINTER_NOTIFY_OPTIONS_TYPE pJobTypes = new PRINTER_NOTIFY_OPTIONS_TYPE(); + lpTypes = Marshal.AllocHGlobal(bytesNeeded); + Marshal.StructureToPtr(pJobTypes, lpTypes, true); + } + } + + public enum PRINTERNOTIFICATIONTYPES + { + PRINTER_NOTIFY_TYPE = 0, + JOB_NOTIFY_TYPE = 1 + } + + [StructLayout(LayoutKind.Sequential)] + public class PRINTER_NOTIFY_OPTIONS_TYPE + { + public const int JOB_FIELDS_COUNT = 24; + public const int PRINTER_FIELDS_COUNT = 23; + + public Int16 wJobType; + public Int16 wJobReserved0; + public Int32 dwJobReserved1; + public Int32 dwJobReserved2; + public Int32 JobFieldCount; + public IntPtr pJobFields; + public Int16 wPrinterType; + public Int16 wPrinterReserved0; + public Int32 dwPrinterReserved1; + public Int32 dwPrinterReserved2; + public Int32 PrinterFieldCount; + public IntPtr pPrinterFields; + + private void SetupFields() + { + if (pJobFields.ToInt32() != 0) + { + Marshal.FreeHGlobal(pJobFields); + } + + if (wJobType == (short)PRINTERNOTIFICATIONTYPES.JOB_NOTIFY_TYPE) + { + JobFieldCount = JOB_FIELDS_COUNT; + pJobFields = Marshal.AllocHGlobal((JOB_FIELDS_COUNT * 2) - 1); + + Marshal.WriteInt16(pJobFields, 0, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_PRINTER_NAME); + Marshal.WriteInt16(pJobFields, 2, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_MACHINE_NAME); + Marshal.WriteInt16(pJobFields, 4, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_PORT_NAME); + Marshal.WriteInt16(pJobFields, 6, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_USER_NAME); + Marshal.WriteInt16(pJobFields, 8, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_NOTIFY_NAME); + Marshal.WriteInt16(pJobFields, 10, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_DATATYPE); + Marshal.WriteInt16(pJobFields, 12, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_PRINT_PROCESSOR); + Marshal.WriteInt16(pJobFields, 14, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_PARAMETERS); + Marshal.WriteInt16(pJobFields, 16, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_DRIVER_NAME); + Marshal.WriteInt16(pJobFields, 18, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_DEVMODE); + Marshal.WriteInt16(pJobFields, 20, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_STATUS); + Marshal.WriteInt16(pJobFields, 22, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_STATUS_STRING); + Marshal.WriteInt16(pJobFields, 24, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_SECURITY_DESCRIPTOR); + Marshal.WriteInt16(pJobFields, 26, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_DOCUMENT); + Marshal.WriteInt16(pJobFields, 28, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_PRIORITY); + Marshal.WriteInt16(pJobFields, 30, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_POSITION); + Marshal.WriteInt16(pJobFields, 32, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_SUBMITTED); + Marshal.WriteInt16(pJobFields, 34, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_START_TIME); + Marshal.WriteInt16(pJobFields, 36, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_UNTIL_TIME); + Marshal.WriteInt16(pJobFields, 38, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_TIME); + Marshal.WriteInt16(pJobFields, 40, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_TOTAL_PAGES); + Marshal.WriteInt16(pJobFields, 42, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_PAGES_PRINTED); + Marshal.WriteInt16(pJobFields, 44, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_TOTAL_BYTES); + Marshal.WriteInt16(pJobFields, 46, (short)PRINTERJOBNOTIFICATIONTYPES.JOB_NOTIFY_FIELD_BYTES_PRINTED); + } + + if (pPrinterFields.ToInt32() != 0) + { + Marshal.FreeHGlobal(pPrinterFields); + } + + if (wPrinterType == (short)PRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_TYPE) + { + PrinterFieldCount = PRINTER_FIELDS_COUNT; + pPrinterFields = Marshal.AllocHGlobal((PRINTER_FIELDS_COUNT - 1) * 2); + + Marshal.WriteInt16(pPrinterFields, 0, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_SERVER_NAME); + Marshal.WriteInt16(pPrinterFields, 2, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_PRINTER_NAME); + Marshal.WriteInt16(pPrinterFields, 4, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_SHARE_NAME); + Marshal.WriteInt16(pPrinterFields, 6, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_PORT_NAME); + Marshal.WriteInt16(pPrinterFields, 8, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_DRIVER_NAME); + Marshal.WriteInt16(pPrinterFields, 10, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_COMMENT); + Marshal.WriteInt16(pPrinterFields, 12, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_LOCATION); + Marshal.WriteInt16(pPrinterFields, 14, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_SEPFILE); + Marshal.WriteInt16(pPrinterFields, 16, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_PRINT_PROCESSOR); + Marshal.WriteInt16(pPrinterFields, 18, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_PARAMETERS); + Marshal.WriteInt16(pPrinterFields, 20, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_DATATYPE); + Marshal.WriteInt16(pPrinterFields, 22, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_ATTRIBUTES); + Marshal.WriteInt16(pPrinterFields, 24, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_PRIORITY); + Marshal.WriteInt16(pPrinterFields, 26, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_DEFAULT_PRIORITY); + Marshal.WriteInt16(pPrinterFields, 28, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_START_TIME); + Marshal.WriteInt16(pPrinterFields, 30, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_UNTIL_TIME); + Marshal.WriteInt16(pPrinterFields, 32, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_STATUS_STRING); + Marshal.WriteInt16(pPrinterFields, 34, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_CJOBS); + Marshal.WriteInt16(pPrinterFields, 36, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_AVERAGE_PPM); + Marshal.WriteInt16(pPrinterFields, 38, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_TOTAL_PAGES); + Marshal.WriteInt16(pPrinterFields, 40, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_PAGES_PRINTED); + Marshal.WriteInt16(pPrinterFields, 42, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_TOTAL_BYTES); + Marshal.WriteInt16(pPrinterFields, 44, (short)PRINTERPRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_FIELD_BYTES_PRINTED); + } + } + + public PRINTER_NOTIFY_OPTIONS_TYPE() + { + wJobType = (short)PRINTERNOTIFICATIONTYPES.JOB_NOTIFY_TYPE; + wPrinterType = (short)PRINTERNOTIFICATIONTYPES.PRINTER_NOTIFY_TYPE; + + SetupFields(); + } + } + + [StructLayout(LayoutKind.Sequential)] + public struct PRINTER_NOTIFY_INFO + { + public uint Version; + public uint Flags; + public uint Count; + } + + + [StructLayout(LayoutKind.Sequential)] + public struct PRINTER_NOTIFY_INFO_DATA_DATA + { + public uint cbBuf; + public IntPtr pBuf; + } + + [StructLayout(LayoutKind.Explicit)] + public struct PRINTER_NOTIFY_INFO_DATA_UNION + { + [FieldOffset(0)] + private uint adwData0; + [FieldOffset(4)] + private uint adwData1; + [FieldOffset(0)] + public PRINTER_NOTIFY_INFO_DATA_DATA Data; + public uint[] adwData + { + get + { + return new uint[] { this.adwData0, this.adwData1 }; + } + } + } + + // Structure borrowed from http://lifeandtimesofadeveloper.blogspot.com/2007/10/unmanaged-structures-padding-and-c-part_18.html. + [StructLayout(LayoutKind.Sequential)] + public struct PRINTER_NOTIFY_INFO_DATA + { + public ushort Type; + public ushort Field; + public uint Reserved; + public uint Id; + public PRINTER_NOTIFY_INFO_DATA_UNION NotifyData; + } + +} diff --git a/22hours_print_api/22hours_print_api/Program.cs b/22hours_print_api/22hours_print_api/Program.cs new file mode 100644 index 0000000..75d6f81 --- /dev/null +++ b/22hours_print_api/22hours_print_api/Program.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using _22hours_print_api.Monitor; +using _22hours_print_api.SpoolAPI; + +namespace _22hours_print_api.Monitor +{ + class Program + { + public static AutoResetEvent Ev = new AutoResetEvent(false); + public static AutoResetEvent Func1 = new AutoResetEvent(false); + public static AutoResetEvent Func2 = new AutoResetEvent(false); + + static void Main(string[] args) + { + Monitor M = new Monitor(); + Ev.WaitOne(); + } + } +} diff --git a/22hours_print_api/22hours_print_api/Properties/AssemblyInfo.cs b/22hours_print_api/22hours_print_api/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0dd215e --- /dev/null +++ b/22hours_print_api/22hours_print_api/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("22hours_print_api")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("22hours_print_api")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("45081b42-1428-47b3-88ce-974e4787337a")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]