// SetLicense.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "sense4.h"
#include <stdio.h>
#include "AccKey.h"

//Only available for modules of net device.
int main(int argc, char* argv[])
{
	SENSE4_CONTEXT * pCtx = NULL;
	DWORD			dwRet;
	BYTE			pPin[24]={0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,
							  0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,
							  0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38};
	DWORD			dwBytesWritten = 0;


	//Access key
	pCtx = AccessKey();
	if(pCtx == NULL)
	{
		printf("Access device failed.");
		return 0;
	}
	
	//Change current directory to \0001
	dwRet = S4ChangeDir(pCtx,"\\0001");

	//Verify DEV PIN
	dwRet=S4VerifyPin(pCtx,pPin,24,S4_DEV_PIN);


	//Set license number(less than or equals to 64)
	dwRet=S4WriteFile(pCtx,NULL,0,NULL,0,45,&dwBytesWritten, S4_SET_LICENCES,0);


	//.......Add your code here......//

	//Close device
	S4Close(pCtx);

	//Free memory
	free(pCtx);
	pCtx = NULL;

	return 0;
}
