#include <windows.h>
#define PORTWELL_4720_OPEN     10  // Control Code for opening cash drawer 1 of model number 4720 mainboard
#define PORTWELL_4720_STATUS   11  // Control Code for getting status of cash drawer 1 of model number 4720 mainboard
#define PORTWELL_4720_OPEN2	   24  // Control Code for opening cash drawer 2 of model number 4720 mainboard
#define PORTWELL_4720_STATUS2  25  // Control Code for getting status of cash drawer 2 of model number 4720 mainboard
#define CREATE_FILE_FAILED     -1
#define DEVICE_CONTROL_FAILED  -2
#define PORTWELL_4720_CASH_DRAWER_IS_OPEN   1
#define PORTWELL_4720_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 PortwellGetCashDrawerStatus(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", PORTWELL_4720_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 = PortwellGetCashDrawerStatus("\\\\.\\FEC_cash", PORTWELL_4720_STATUS); //for cash drawer 1
 
	 
 //ret=0  -> success
 //ret=-1 -> create file failed
 //ret=-2 -> device io control failed	 
 ret = DeviceControl("\\\\.\\FEC_cash", PORTWELL_4720_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 = PortwellGetCashDrawerStatus("\\\\.\\FEC_cash", PORTWELL_4720_STATUS2); //for cash drawer 2

}