调用vc的dll 返回 char * 怎样接收??? 我快疯了!!!不揭帖不睡觉
VC 的头文件这样声明的
_PORT_ char *OCode(unsigned long fIDMode,bool fReference,char *lpFileName);
我这样调用
[DllImport(@"OCode.dll")]
public static extern StringBuilder OCode(long fIDMode, bool fReference,StringBuilder s);
StringBuilder a1 = new StringBuilder("132132");
StringBuilder b1 = new StringBuilder();
b1 = OCode(2, false, ddd);
不管怎样都得不到返回值,高手给我看看,调用是否正确???
------解决方案--------------------
vc:unsigned long -->c#:uint
------解决方案--------------------
[DllImport(@"OCode.dll")]
public static extern StringBuilder OCode(uint fIDMode, bool fReference,StringBuilder s);
试一试
------解决方案--------------------
[DllImport(@"OCode.dll")]
public static extern StringBuilder OCode(uint fIDMode, bool fReference,StringBuilder s);
------解决方案--------------------
stringbuilder是引用类型 -- 》 char*
string类型不能作为指针用
实在不行直接设置一个不安全代码段 直接对着引用调用
------解决方案--------------------[DllImport(@"OCode.dll")]
public static extern StringBuilder OCode(uint fIDMode, bool fReference,string s);
------解决方案--------------------[DllImport(@"OCode.dll", EntryPoint = "JL_GetOneReport", CallingConvention = CallingConvention.StdCall)]
public static extern string OCode(uint fIDMode, bool fReference, string s);
[DllImport(@"OCode.dll", EntryPoint = "JL_GetOneReport", CallingConvention = CallingConvention.StdCall)]
public static extern string OCode(uint fIDMode, bool fReference, ref string s);