#include <windows.h>
#define ADVANTECH_6722_OPEN     26  // Control Code for opening cash drawer 1 of model number 6722 mainboard
#define ADVANTECH_6722_STATUS   27  // Control Code for getting status of cash drawer 1 of model number 6722 mainboard
#define ADVANTECH_6722_OPEN2    28  // Control Code for opening cash drawer 2 of model number 6722 mainboard
#define ADVANTECH_6722_STATUS2  29  // Control Code for getting status of cash drawer 2 of model number 6722 mainboard
#define CREATE_FILE_FAILED     -1
#define DEVICE_CONTROL_FAILED  -2
#define ADVANTECH_6722_CASH_DRAWER_IS_OPEN   1
#define ADVANTECH_6722_CASH_DRAWER_IS_CLOSED 0

// szDeviceName ->Device Driver Name
// CTL_ID-> Control Code

__declspec( dllimport ) DWORD WINAPI DeviceControl(LPSTR szDeviceName, DWORD CTL_ID);
__declspec( dllimport ) DWORD WINAPI AdvantechGetCashDrawerStatus(LPSTR szDeviceName,DWORD CTL_ID);


void main()
{
 DWORD ret;
 
 //ret=0  -> success
 //ret=-1 -> create file failed
 //ret=-2 -> device io control failed
 ret = DeviceControl("\\\\.\\FEC_cash", ADVANTECH_6722_OPEN); //for cash drawer 1
 
 //ret=0  -> cash drawer is closed
 //ret=1  -> cash drawer is open
 //ret=-1 -> create file failed
 //ret=-2 -> device io control failed
 ret = AdvantechGetCashDrawerStatus("\\\\.\\FEC_cash", ADVANTECH_6722_STATUS); //for cash drawer 1
 
	 
  //ret=0  -> success
 //ret=-1 -> create file failed
 //ret=-2 -> device io control failed
 ret = DeviceControl("\\\\.\\FEC_cash", ADVANTECH_6722_OPEN2); //for cash drawer 2
 
 //ret=0  -> cash drawer is closed
 //ret=1  -> cash drawer is open
 //ret=-1 -> create file failed
 //ret=-2 -> device io control failed
 ret = AdvantechGetCashDrawerStatus("\\\\.\\FEC_cash", ADVANTECH_6722_STATUS2); //for cash drawer 2
 
 
 
 
}