C++中调用的DLL格式如下
DLLIMPORT BOOL PTP_SetDefaultPath(CString path);C#中如何写?主要是CString如何定义?
DLLIMPORT BOOL PTP_SetDefaultPath(CString path);C#中如何写?主要是CString如何定义?
解决方案 »
- 求解:DataGridView数据导入到Excel问题
- 谁知道通过mysql生成 C#实体类的工具?
- 数据库的增删改,SQL语句与Dataset的性能问题,大家帮忙看看!
- 刚学.net,在看MSDN里的例程,有一个错误不知道什么原因请帮忙...
- 在c#里面怎样实现~~~窗体之间传递消息~~~~~(高手请近)~~~?????????????????
- 一个插入数据的问题。。求达人看看~~
- 如何开始一个winForm和webUI共用一个业务逻辑的项目?
- 关于随机数的问题,抢分
- C#动态编译类CSScriptLibrary.dll,求支持linq的。
- 字符转整型的问题
- c#,请教这些接口的关系
- c# 虚拟鼠标点击 webberwser 控件模拟虚拟操作,仿真人操作点击大家一起交流下!
用c++再做一次包装,把cstring 转为 char* or 直接转为system::string^
是不是意味着无法使用C#了?
[System.Runtime.InteropServices.DllImportAttribute("dll文件名", EntryPoint="PTP_SetDefaultPath")]
[return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool PTP_SetDefaultPath([System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string path) ;如果是unicode 方法定义为:
[System.Runtime.InteropServices.DllImportAttribute("你的dll文件名", EntryPoint="PTP_SetDefaultPath")]
[return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool PTP_SetDefaultPath([System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string path) ;
用c语中间写个过渡的。
像这样用MFC做接口,就算大家都用同一个版本的MFC,换个编译配置就不兼容了。
话说接口参数类型换成BSTR不就了吗?
是不是意味着无法使用C#了?
不是让你修改他的,是再做一个C++dll,写一个函数,那个CString参数在这里用char*,你这个函数负责把char*转换成Cstring的给那个厂商的dll,你的C#代码调用你新写的这个dll
是不是意味着无法使用C#了?
不是让你修改他的,是再做一个C++dll,写一个函数,那个CString参数在这里用char*,你这个函数负责把char*转换成Cstring的给那个厂商的dll,你的C#代码调用你新写的这个dll
已经这样搞了