[高手进来]C#调用vs2005 vc++ 智能设备编写的dll 出现的问题 急

dragonlyf 2008-09-22 10:43:33
vc++的“MFCDes.dll”导出函数
__declspec (dllexport) bool DesGo(char *Out,char *In,long datalen,const char *Key,int keylen,bool Type = 0)
在c#中调用
DllImport("MFCDes.dll", SetLastError = true)]
public static extern StringBuilder Des(string strOut,string strIn, long dataLen,string key,int keyLen, bool type);
怎么调用都报错。

后来我在vc++中 写了几个最简单的函数 int Sum(int a,int b) 和 char *StringSum(char *a,char*b)分别调用
其中int型没错,凡参数涉及字符串的都调用失败。请问我哪里出错了,请高手指点!急
...全文
55 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
dragonlyf 2008-09-22
  • 打赏
  • 举报
回复
[DllImport("MFCDes.dll")]
public static extern string mySum(string a, string b);

private void button1_Click(object sender, EventArgs e)
{
string aa = "aaaa";
string b = "";
MessageBox.Show(mySum(aa, b));
}
dragonlyf 2008-09-22
  • 打赏
  • 举报
回复
这是简单的两个字符串的
[DllImport("MFCDes.dll")]
public static extern string mySum(string a, ref string b);

private void button1_Click(object sender, EventArgs e)
{
string aa = "aaaa";
string b = "";
MessageBox.Show(mySum(aa, ref b));
}
lenux 2008-09-22
  • 打赏
  • 举报
回复
把你调用的代码贴出来看看。

怀疑你传入了unicode的字符串,而需要的是ascii的char。

19,503

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 嵌入开发(WinCE)
社区管理员
  • 嵌入开发(WinCE)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧