#include "stdafx.h"
#include "R-HH-M3O-LEG42-USB-SDK-DEMO.h"
#include "DlgGeneralnfo.h"
#include "R-HH-M3O-LEG42-USB-SDK.h"


IMPLEMENT_DYNAMIC(CDlgGeneralnfo, CPropertyPage)

CDlgGeneralnfo::CDlgGeneralnfo()
	: CPropertyPage(CDlgGeneralnfo::IDD)
{

}

CDlgGeneralnfo::~CDlgGeneralnfo()
{
}

void CDlgGeneralnfo::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EDIT_READER_TYPE, m_ctrlReaderType);
	DDX_Control(pDX, IDC_EDIT_HARDWARE_REV, m_ctrlHardwareRev);
	DDX_Control(pDX, IDC_EDIT_POWER, m_ctrlPower);
	DDX_Control(pDX, IDC_EDIT_BOOT_LOADER, m_ctrlBootLoader);
	DDX_Control(pDX, IDC_EDIT_FIRMWARE, m_ctrlFirmware);
	DDX_Control(pDX, IDC_EDIT_CRYPT_MODE, m_ctrlCryptMode);
}


BEGIN_MESSAGE_MAP(CDlgGeneralnfo, CPropertyPage)
	ON_BN_CLICKED(IDOK, &CDlgGeneralnfo::OnBnClickedOk)
END_MESSAGE_MAP()



void CDlgGeneralnfo::OnBnClickedOk()
{
	SDKHANDLE hReader = OpenReader(0x01);
	if(hReader != NULL)
	{
		USES_CONVERSION;

		char szData[MAX_PATH]; DWORD dwSize = MAX_PATH;
		ZeroMemory(szData, MAX_PATH);
		GetReaderCaps(hReader, ERD_READER_TYPE, (BYTE*)szData, dwSize);
		m_ctrlReaderType.SetWindowText(A2T(szData));

		dwSize = MAX_PATH;
		GetReaderCaps(hReader, ERD_HARDWARE_REV, (BYTE*)szData, dwSize);
		m_ctrlHardwareRev.SetWindowText(A2T(szData));

		dwSize = MAX_PATH;
		GetReaderCaps(hReader, ERD_POWER, (BYTE*)szData, dwSize);
		m_ctrlPower.SetWindowText(A2T(szData));

		dwSize = MAX_PATH;
		GetReaderCaps(hReader, ERD_BOOT_LOADER, (BYTE*)szData, dwSize);
		m_ctrlBootLoader.SetWindowText(A2T(szData));

		dwSize = MAX_PATH;
		GetReaderCaps(hReader, ERD_FIRMWARE, (BYTE*)szData, dwSize);
		m_ctrlFirmware.SetWindowText(A2T(szData));

		dwSize = MAX_PATH;
		GetReaderCaps(hReader, ERD_CRYPT_MODE, (BYTE*)szData, dwSize);
		m_ctrlCryptMode.SetWindowText(A2T(szData));

		CloseReader(hReader);
	}
}
