C# 调用C写的DLL时 对应的int* 类型返回值转化为 IntPtr

来源:互联网 发布:天刀太白妹子捏脸数据 编辑:程序博客网 时间:2024/05/19 19:39

C中代码:

[cpp] view plaincopy
  1. int* read( char *filename )  
  2. {  
  3.     .......  
  4. }  

C#中代码:
[csharp] view plaincopy
  1. [DllImport("myC.dll", EntryPoint = "read", CharSet = CharSet.Auto)]  
  2. public static extern IntPtr read(ref byte filename);  
调用示例:
[csharp] view plaincopy
  1. string name = @"d:\result\Gaussian_6_0.3.jpg";  
  2.             byte[] filename = new byte[100];  
  3.             for (int i = 0; i < name.Length; i++)  
  4.             {  
  5.                 filename[i] = (byte)name[i];  
  6.             } 
  7.             IntPrt data = new IntPtr();
  8.             data = liblept168.read(ref filename[0]); 

原创粉丝点击