MFC里有现成函数将十六进制整型转换成十进制整型吗?

如题,十六进制数是整型的,要转换成的十进制也要是int型的,转换后赋值给m,有现成的函数调用嘛,怎么调用?如果没有咋写。

CString strDec, strHex;
strHex = _T("12AF"); //16进制
DWORD dwHex = strtoul(strHex, NULL, 16);
strDec.Format(_T("%ld"), dwHex);
strDec为10进制,如果要转换成数字,
DWORD dwHex = strtoul(strHex, NULL, 16);
long x = (long)dwHex;

自己写也可以,代码不写了,思路说下
从最右边的字符开始,乘以16的n-1次方
比如12AF转换成10进制,就是
F(15) * 16的0次方(也就是1)+ A (10)* 16的1次方(也就是16)+ 2 * 16*16 + 1*16*16*16

没有。需要自己实现。提供下面两种方式
第一种,参数也是int 型16进制
unsigned int htd(unsigned int a)
{
unsigned int b,c;
b=a%10;
c=b;
a=a/10;
b=a%10;
c=c+(b<<4);
a=a/10;
b=a%10;
c=c+(b<<8);
a=a/10;
b=a%10;
c=c+(b<<12);
return c;
}

第二种,参数是16进制字符串

int getIndexOfSigns(char ch)
{
if(ch >= '0' && ch <= '9')
{
return ch - '0';
}
if(ch >= 'A' && ch <='F')
{
return ch - 'A' + 10;
}
if(ch >= 'a' && ch <= 'f')
{
return ch - 'a' + 10;
}
return -1;
}

long hexToDec(char *source)
{
long sum = 0;
long t = 1;
int i, len;

len = strlen(source);
for(i=len-1; i>=0; i--)
{
    sum += t * getIndexOfSigns(*(source + i));
    t *= 16;
}  

return sum;