/*****************************************************************************************
*  Copyright (c) 2004, Beijing Senselock Data Security Centre
*  All rights reserved.
*
*  Filename£ºsample_7.c
*          
*  Briefs£º  The purpose of this snippet is to demonstrate how to get SenseLock EL device type. 
*            
*            
*  History:        
*  --------------------------------------------------------        
*            11/08/2004 v1.0.0.0 Lihua created
*            
*            
*******************************************************************************************/

#include <stdio.h>
#include <conio.h>
#include <assert.h>

#include "..\..\inc\win32\sense4.h"
#include "..\..\common\common.h"


int main(int argc, char* argv[])
{
	SENSE4_CONTEXT stS4Ctx = {0};
	unsigned long dwResult = 0;
	unsigned char bDeviceType = 0;
		
	printf("Open first SenseLock EL device...\n");
	if (!(dwResult = OpenS4ByIndex(FIRST_S4_INDEX, &stS4Ctx)))
	{
		return 1;
	} 
	printf("Success!\n");

	printf("Get SenseLock EL device type ...\n");
	dwResult = S4Control(&stS4Ctx, S4_GET_DEVICE_TYPE, NULL, 0, &bDeviceType, sizeof(bDeviceType), NULL);
	if (dwResult != S4_SUCCESS) 
	{
		printf("Get SenseLock EL device type failed! <error code: 0x%08x>\n", dwResult);
		S4Close(&stS4Ctx);
		return 1;
	}
	printf("Success! \n");
	switch(bDeviceType) 
	{
		case S4_LOCAL_DEVICE:
			printf("The SenseLock EL device is of desktop version.\n");
			break;
		case S4_MASTER_DEVICE:
			printf("The SenseLock EL device is of network version - master device.\n");
			break;
		case S4_SLAVE_DEVICE:
			printf("The SenseLock EL device is of network version - slave device.\n");
			break;
		default:
			printf("Unexpected device type!\n");
	}

	
	S4Close(&stS4Ctx);
    getch(); 
	return dwResult;
}





















