请高手帮忙翻译一下以下程序,我有一段VB写的程序调用一个C++写的DLL。我想麻烦各位帮忙翻译成C#的,感谢了!
Private Declare Function GetPeopleName Lib "termb.dll" (ByVal lpBuffer As String, ByVal strLen As Integer) As Integer
Dim str As String
Dim iRet As Integer
str = Space$(256)
iRet = GetPeopleName(str, 256)
Text1(0).Text = Trim(str)
我这样写不出错,但是str不返回数据,麻烦帮忙看看哪里错了。
[DllImport("termb.dll")]
static extern int GetPeopleName(string lpBuffer, uint strLen);
string str;
int iRet;
iRet = GetPeopleName(str, 256);
textBox1.Text=str;
10 个解决方案
[DllImport("termb.dll")]
static extern int GetPeopleName(StringBuilderlpBuffer, uint strLen);
StringBuilder sb = new StringBuilder(256);
int iRet;
iRet = GetPeopleName(sb, 256);
textBox1.Text=sb.ToString();
string str;
int iRet;
str = Strings.Space(256);
iRet = GetPeopleName(str, 256);
Text1(0).Text = Strings.Trim(str);
Avoid(千金散尽还复来)
你的是完全正确的。谢谢。请接分!