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

C中代码:

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

C#中代码:
[csharp] view plain copy
  1. [DllImport("myC.dll", EntryPoint = "read", CharSet = CharSet.Auto)]  
  2. public static extern IntPtr read(ref byte filename);  
调用示例:
[csharp] view plain copy
  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]); 

你可能感兴趣的:(C#)