LPCTSTR __IntToHex(BYTE value,BOOL HaveSpace=TRUE)
{
static TCHAR buf[2];
if(HaveSpace)
_stprintf(buf,_T("%02X "),value);
else
_stprintf(buf,_T("%02X"),value);
return buf;
}
//--------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
//
// HexToInt()
// 将Hex字符转化为Int
//-----------------------------------------------------------------------------------
static int HexToInt(char Hi,char Lo)
{
Lo = toupper(Lo);
if (Lo >= 'A' && Lo <= 'F')
Lo = Lo - 'A'+10;
else if (Lo >= '0' && Lo <= '9')
Lo = Lo-'0';
else
{
::SetLastError(ERROR_INVALID_DATA);
throw NULL;
}
Hi = toupper(Hi);
if (Hi >= 'A' && Hi <= 'F')
Hi = Hi - 'A'+10;
else if (Hi >= '0' && Hi <= '9')
Hi = Hi-'0';
else
{
::SetLastError(ERROR_INVALID_DATA);
throw NULL;
}
return Hi<<4|Lo;
}