C# :Test中有个方法 TestFunc(string str)
c++中:Test ^test = gcnew Test(); test->TestFunc(p1); 参数p1该怎么传呢,比如我要传aaa?
C++调用C#的dll时,怎么传string类型参数
答案:3 悬赏:60
解决时间 2021-02-17 01:55
- 提问者网友:践踏俘获
- 2021-02-16 07:45
最佳答案
- 二级知识专家网友:為→妳鎖鈊
- 2021-02-16 08:19
转换格式就可以了;
CString strTest="aaa";
System::String^ p1 = gcnew String(strTest);
test->TestFunc(p1);
CString strTest="aaa";
System::String^ p1 = gcnew String(strTest);
test->TestFunc(p1);
全部回答
- 1楼网友:何必打扰
- 2021-02-16 10:48
dll 导出函数声明: int winapi open( char* name );
c#声明:
[dllimport("test.dll", entrypoint = "open", charset = charset.ansi, callingconvention = callingconvention.winapi, exactspelling = false)]
public static extern int open(string chost);
c#调用:
string url = this.textbox1.text; //控件的值
open( url );
- 2楼网友:废途浑身病态
- 2021-02-16 09:16
System::String^ p1 = gcnew System::String(L"aaa");
test->TestFunc(p1);
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯