Chinaunix首页 | 论坛 | 博客
  • 博客访问: 39922
  • 博文数量: 11
  • 博客积分: 530
  • 博客等级: 中士
  • 技术积分: 140
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-22 21:56
文章分类

全部博文(11)

文章存档

2010年(1)

2009年(3)

2008年(7)

我的朋友

分类: C/C++

2008-11-25 20:59:19

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) |
给主人留下些什么吧!~~