#include <windows.h>
#define CREATE_FILE_FAILED     -1
#define DEVICE_CONTROL_FAILED  -2

#define CROSSBOW_3710_OPEN1  12 // Control Code for opening cash drawer 1 of crossbow 3710 mainboard
#define CROSSBOW_3710_STATUS1 13  // Control Code for getting status of cash drawer 1 of crossbow 3710 mainboard
#define CROSSBOW_3710_OPEN2  14   // Control Code for opening cash drawer 2 of crossbow 3710 mainboard
#define CROSSBOW_3710_STATUS2  15 // Control Code for getting status of cash drawer 2 of crossbow 3710 mainboard
#define  CROSSBOW_3710_CASH_DRAWER_IS_OPEN   1
#define  CROSSBOW_3710_CASH_DRAWER_IS_CLOSED    0




// szDeviceName ->Device Driver Name
// CTL_ID-> Control Code
__declspec( dllimport ) DWORD WINAPI LoadService(LPSTR szService, LPSTR szImagePath);

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

__declspec( dllimport ) DWORD WINAPI UnloadService(LPSTR szService, BOOL bUninstall);

void main()
{
 DWORD ret;

 //ret=0,load driver successfully
 //ret!=0,load driver failed
 ret = LoadService("FEC_cash", "system32\\drivers\\FEC_cash.sys");
 
	
 //ret=0  -> success
 //ret=-1 -> create file failed
 //ret=-2 -> device io control failed
 ret = DeviceControl("\\\\.\\FEC_cash", CROSSBOW_3710_OPEN1); //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 = Crossbow3710GetCashDrawerStatus("\\\\.\\FEC_cash", CROSSBOW_3710_STATUS1); //for cah drawer 1


 ret = DeviceControl("\\\\.\\FEC_cash", CROSSBOW_3710_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 = Crossbow3710GetCashDrawerStatus("\\\\.\\FEC_cash", CROSSBOW_3710_STATUS2); //for cah drawer 2
 //unload driver	 
 ret = UnloadService("FEC_cash", TRUE);





}