char szHex[] = "0X0000FFFF";如何转成DWORD dwHex == 0X0000FFFF;   ???给出代码,立即给分。

解决方案 »

  1.   

    DWORD StrToInt2(CString str)
    {
    if( str.GetLength() <= 2 )
    return 0 ;  str.MakeUpper() ; 
    if( "0X" != str.Left(2) )
    return 0 ;  str.Delete(0,2) ;  int sum = 0 ; 
    int index = 0  ; 
    while( index != str.GetLength() && '0'==str[index])  
    index ++ ; while( index != str.GetLength() )
    {
    char ch = str[index++] ; 
    if( ch>= '0' && ch<='9' )
    {
    sum = sum * 16 + ch-'0' ; 
    continue ; 
    }
    if( ch>='A' && ch<='F' )
    {
    sum = sum * 16 + ch-'A'+10 ; 
    continue ; 
    }
    }
    return sum ; 
    }
      

  2.   

    查MSDN ,可以查到 StrToInt
    int StrToInt( 
        LPCTSTR lpSrc 
        );#define StrToLong StrToInt还有 StrToIntExBOOL StrToIntEx(
        LPCTSTR pszString,
        DWORD dwFlags,
        int FAR * piRet
        );
      

  3.   

    引入头文件 #include "SHLWAPI.H"(在 C:\Program Files\Microsoft Visual Studio\VC98\Include 中)
    引入库   SHLWAPI.LIB (在 C:\Program Files\Microsoft Visual Studio\VC98\Lib 中 )
    然后调用 StrToIntEx这样就可以了
    int value ; 
    StrToIntEx(szHex,STIF_SUPPORT_HEX,&value) ;
      

  4.   

    DWORD dwHex=0;
    char szHex[] = "0X0000FFFF";
    sscanf(szHex,"0X%08X",&dwHex);
      

  5.   

    int sum = 0 ;?
    不是DWORD嘛!^_^
      

  6.   

    在 MSDN上查到 StrToInt 和 StrToIntEx ,但是不知道怎么才能用。抢分心切,自己写了一个 StrToInt2,嘿嘿,*^_^*自己写的肯定没有库里面的好,大家不要笑话俺。
      

  7.   

    同意DentistryDoctor(牙科医生)!
    ^_^
      

  8.   

    DentistryDoctor(牙科医生) :   厉害哦 。
      

  9.   

    sprintf();函数也有同样的效果,还可以用IntToHex函数直接转