十进制转十六进制:
CString DecToHex(unsigned int uDec)
{
CString strRet;
CString strTemp;
strTemp.Format("%X", uDec);
switch (strTemp.GetLength())
{
case 0:
strRet.Format("0x00000000");
break;
case 1:
strRet.Format("0x0000000%s", strTemp);
break;
case 2:
strRet.Format("0x000000%s", strTemp);
break;
case 3:
strRet.Format("0x00000%s", strTemp);
break;
case 4:
strRet.Format("0x0000%s", strTemp);
break;
case 5:
strRet.Format("0x000%s", strTemp);
break;
case 6:
strRet.Format("0x00%s", strTemp);
break;
case 7:
strRet.Format("0x0%s", strTemp);
break;
case 8:
strRet.Format("0x%s", strTemp);
break;
default:
AfxMessageBox("address is beyond 32 bits");
break;
}
return strRet;
}