1.首先是怎么调用问题。
建立vc DLL工程。编写def文件 导出你想导出的函数。典型的def文件格式为
LIBRARY "face"
EXPORTS
face_init @ 1
face_destroy @ 2
face_getdoc @ 3
face_getreplyid @ 4
face_getdocinfo @ 5
LIBRARY 为库的名称(文件名) ,@后是函数在DLL中的顺序(如调用无关)
然后在C# 文件中利用DllImport 来引入,如下所示:
[DllImport("lib\\face.dll")]
private static extern int function(string location, int id, ref string title);
类中直接使用就可以了。
2.关于对应的参数问题?
比如C++中是 char* C#是什么类型呢? char** 有对应什么类型呢?
以下是一个例子:
private static extern int function(string location, int id, ref string title);
int function(char* location ,int id, char** title);
可以看到一般值类型基本就不变,
char* -> string
char** -> ref string
阅读(1443) | 评论(0) | 转发(0) |