获取汉字的ASCII码,完成VB的Asc函数功能

 static INT_PTR StatusName(CString csTxt)
 {
  CString csTemp;
  csTemp = csTxt;
  char * pchar = new char [csTemp.GetLength()*2 + 1];
  memset(pchar, 0, csTemp.GetLength()*2+ 1);
  WideCharToMultiByte( CP_ACP, 0, csTemp, -1, pchar, csTemp.GetLength()*2 + 1, NULL, NULL );
  unsigned char buf1[2];
  buf1[0] = pchar[1];
  buf1[1] = pchar[0];
  short iAsccii = 0;
  memcpy(&brt,buf1,2);
  delete [] pchar;
  pchar = NULL;
  return (INT_PTR)iAsccii;
 }

测试环境:VC2010

你可能感兴趣的:(VC)