[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”进行了怎样的处理???求解处理过程???
}
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”进行了怎样的处理???求解处理过程???
}
LZ问的是对“int dwRet”的处理过程,也就是这两句:
char[] asciiChars = new char[gb2312.GetCharCount(asciiBytes, 0, dwRet)];
gb2312.GetChars(asciiBytes, 0, dwRet, asciiChars, 0);termb.dll这个库有关系吗?如果这个库返回的是ANSI
应该就是这样处理,不知小弟说的对否???
1、Encoding.GetEncoding("gb2312");
2、new char[gb2312.GetCharCount(asciiBytes, 0, dwRet)]
3、gb2312.GetChars(asciiBytes, 0, dwRet, asciiChars, 0)