[DllImport("termb.DLL", CallingConvention = CallingConvention.StdCall)]
public static extern int GetPeopleName(Byte[] buf, int iLen);
static string GetName()
        {
            Byte[] asciiBytes = null;
            asciiBytes = new Byte[100];
            int dwRet = GetPeopleName(asciiBytes, 100);
            Encoding gb2312 = Encoding.GetEncoding("gb2312");
            char[] asciiChars = new char[gb2312.GetCharCount(asciiBytes, 0, dwRet)];
            gb2312.GetChars(asciiBytes, 0, dwRet, asciiChars, 0);
            return new string(asciiChars);
这里对Int 类型的“dwRet”进行了怎样的处理???求解处理过程???

        }

解决方案 »

  1.   

    本帖最后由 caozhy 于 2011-04-10 11:05:02 编辑
      

  2.   

    GetPeopleName做了什么操作就是什么操作啊 。看GetPeopleName不就成了
      

  3.   


    LZ问的是对“int dwRet”的处理过程,也就是这两句:
    char[] asciiChars = new char[gb2312.GetCharCount(asciiBytes, 0, dwRet)];
    gb2312.GetChars(asciiBytes, 0, dwRet, asciiChars, 0);termb.dll这个库有关系吗?如果这个库返回的是ANSI
    应该就是这样处理,不知小弟说的对否???
      

  4.   

    不用关系“GetPeopleName”方法啊,想弄明白下面的方法是什么作用:
    1、Encoding.GetEncoding("gb2312");
    2、new char[gb2312.GetCharCount(asciiBytes, 0, dwRet)]
    3、gb2312.GetChars(asciiBytes, 0, dwRet, asciiChars, 0)