c#调用c++写成的dll文件,返回char*,返回数组,用ref接收,byte[] (zz)
来源:互联网 发布:高中物理模拟软件 编辑:程序博客网 时间:2024/06/06 08:25
/ Inclusion guard
#ifndef _DLLTUT_DLL_H_
#define _DLLTUT_DLL_H_
// Make our life easier, if DLL_EXPORT is defined in a file then DECLDIR will do an export
// If it is not defined DECLDIR will do an import
#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif
// Specify "C" linkage to get rid of C++ name mangeling
extern "C"
{
// Declare 2 functions
DECLDIR int Add( int a, int b );
DECLDIR void Function( void );
DECLDIR void GetPrt( char * prtStr );
}
// End the inclusion guard
#endif
#ifndef _DLLTUT_DLL_H_
#define _DLLTUT_DLL_H_
// Make our life easier, if DLL_EXPORT is defined in a file then DECLDIR will do an export
// If it is not defined DECLDIR will do an import
#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif
// Specify "C" linkage to get rid of C++ name mangeling
extern "C"
{
// Declare 2 functions
DECLDIR int Add( int a, int b );
DECLDIR void Function( void );
DECLDIR void GetPrt( char * prtStr );
}
// End the inclusion guard
#endif
static void Main(string[] args)
{
test.Function();
Console.WriteLine("result: " + test.Add(2, 3).ToString());
//string str = "aaddddddddddd";
byte[] str = new byte[12];
test.GetPrt(ref str[0]);
Console.WriteLine(System.Text.Encoding.GetEncoding("GB2312").GetString(str));
Console.ReadLine();
}
}
class test
{
[DllImport("..\\..\\lib\\DLLTest.dll")]
public static extern void Function();
[DllImport("..\\..\\lib\\DllTest.dll")]
public static extern int Add(int i,int j);
[DllImport("..\\..\\lib\\DllTest.dll")]
public static extern void GetPrt(ref byte prtStr);
}
{
test.Function();
Console.WriteLine("result: " + test.Add(2, 3).ToString());
//string str = "aaddddddddddd";
byte[] str = new byte[12];
test.GetPrt(ref str[0]);
Console.WriteLine(System.Text.Encoding.GetEncoding("GB2312").GetString(str));
Console.ReadLine();
}
}
class test
{
[DllImport("..\\..\\lib\\DLLTest.dll")]
public static extern void Function();
[DllImport("..\\..\\lib\\DllTest.dll")]
public static extern int Add(int i,int j);
[DllImport("..\\..\\lib\\DllTest.dll")]
public static extern void GetPrt(ref byte prtStr);
}
0 0
- c#调用c++写成的dll文件,返回char*,返回数组,用ref接收,byte[] (zz)
- c#调用c++写成的dll文件,返回char*,返回数组,用ref接收,byte[] (zz)
- C# 调用C写的DLL时 对应的char* 类型转化为 ref byte
- c#调用c++写成的dll文件
- Axis接收远程调用c# webservice返回的数组
- C# 调用C/C++ Dll(参数含char*指针,返回char*指针)
- [zz]C#调用C生成DLL文件
- C# 调用C++DLL传递的bool型,返回混乱
- C#调用C++Dll字符串返回为空的问题
- C# 调用C++DLL传递的bool型,返回混乱
- C# 调用C++DLL传递的bool型,返回混乱
- Unity使用C#调用C++dll传递指针参数、接收指针返回值
- 接收远程调用webservice返回的数组
- C# 调用C++ dll 方法返回char* 乱码
- 接收包含文件中返回的数组
- C#调用C++的Dll(参数和返回值為char* TCHAR*)
- C#调用C++的Dll(参数和返回值為char* TCHAR*)
- C#返回byte[]给dll的方法,寻求帮助
- MongoDB 3.4 高可用集群搭建(二)replica set 副本集
- 排序网络(Sorting network )构造的C语言实现
- iis连接oracle数据库的历程!
- 几种页面置换算法
- Kotlin & Spring boot 使用@Valid校验无效解决方法
- c#调用c++写成的dll文件,返回char*,返回数组,用ref接收,byte[] (zz)
- 蓝桥杯第四届个人赛
- 用mycat做读写分离:基于 MySQL主从复制
- Android自定义控件
- 17.03.04 泛型
- MongoDB 3.4 高可用集群搭建(三)shard 分片
- java常用的几种线程池比较
- 约瑟夫环问题
- jdk 、 tomacat 的配置