有关IntPtr定义的问题有点晕
C++ 里是
EXPORT int WINAPI Match(void* Minu1, int nMinu1, void* Minu2, int nMinu2);C#里
[DllImport("brmatchCHS.dll", SetLastError=true)]
public static extern int Match(System.IntPtr Minu1, int nMinu1,System.IntPtr Minu2, int nMinu2);
Minu1实际的数据类型应该是byte[]或string
那么我该如何用IntPtr来表示byte[]或string 呢?
C++ 里是
EXPORT int WINAPI Match(void* Minu1, int nMinu1, void* Minu2, int nMinu2);C#里
[DllImport("brmatchCHS.dll", SetLastError=true)]
public static extern int Match(System.IntPtr Minu1, int nMinu1,System.IntPtr Minu2, int nMinu2);
Minu1实际的数据类型应该是byte[]或string
那么我该如何用IntPtr来表示byte[]或string 呢?
将数据从非托管内存块封送到新分配的指定类型的托管对象。
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/cpref/html/frlrfSystemRuntimeInteropServicesMarshalClassPtrToStructureTopic2.asp
public static extern int Match(byte[] Minu1, int nMinu1,System.IntPtr Minu2, int nMinu2);[DllImport("brmatchCHS.dll", SetLastError=true)]
public static extern int Match(String Minu1, int nMinu1,System.IntPtr Minu2, int nMinu2);
例如:string s="a";
我想把s传进Match函数里的Minu1用方法重载好象得不到想要的结果
public static extern int Match(ref String Minu1, int nMinu1,System.IntPtr Minu2, int nMinu2);使用:
String s = "aaa";
Match(ref s, ...);