Specifications

B-3
Appendix B
Implementation in Calling Application
8/6/2010 KR203 Software Integrator Guide P1028248-001 Rev. A
Implementation in Calling Application
1. Open the Printer.
The first step of the implementation is to open the printer required to monitor and get
the Error event and Status even name.
bRet = OpenPrinter(m_csPrinter.GetBuffer(1),
&hPrinter, &pd);
if ((dRet = GetPrinterData(hPrinter, "ErrorEventName",
&dType, (LPBYTE)cTmp, 100, &dNeeded))!=ERROR_SUCCESS)
if ((dRet = GetPrinterData(hPrinter, "StatusEventName",
&dType, (LPBYTE)cTmp, 100, &dNeeded))!=ERROR_SUCCESS)
2. Open the Event Handles.
Open the two event handles and fill these handles into a structure that will pass on to
the new thread.
typedef struct _CStatusThreadInfo
{
HWNDmyHwnd;
DWORDdSleepTime;
HANDLEhPrinter;
HANDLEhError;
HANDLEhStatus;
BOOLm_hStatusEventKillThread;
} CStatusThreadInfo;
if ((cTi.hError = OpenEvent(SYNCHRONIZE, TRUE,
m_csErrorEvent))==NULL)
if ((cTi.hStatus = OpenEvent(SYNCHRONIZE, TRUE,
m_csStatusEvent))==NULL)
Step: Start Monitoring
When all this is done you can start your monitoring
thread.
m_StatusThread = AfxBeginThread( StatusThreadProc,
&cTi, THREAD_PRIORITY_NORMAL,0,0,NULL);