CString str = "12"; //12 CString strTemp = _T(""); int nTemp = (int)strtol(str, NULL, 16); strTemp.Format("%02X", nTemp);