typedef struct TH_PlateIDCfg
{
int nMinPlateWidth;
int nMaxPlateWidth;
int nMaxImageWidth;
int nMaxImageHeight;
unsigned char bVertCompress;
unsigned char bIsFieldImage;
unsigned char bOutputSingleFrame;
unsigned char bMovingImage;
unsigned char bIsNight; 
unsigned char nImageFormat; 
unsigned char * pFastMemory; 
int nFastMemorySize;
unsigned char *pMemory;     /*普通内存的地址,内建的内存管理,避免内存泄漏等问题*/
int nMemorySize; // 普通内存的大小
int (*DMA_DataCopy)(void *dst, void *src,int nSize);
int (*Check_DMA_Finished)();
int nLastError;      // 用于传递错误信息
int nErrorModelSN; // 出错的模块编号
char reserved[120];  //保留
}TH_PlateIDCfg;
这样一个结构体,如何在c#中引用?关键是int (*DMA_DataCopy)(void *dst, void *src,int nSize);
int (*Check_DMA_Finished)();
这两个函数怎么办

解决方案 »

  1.   

    http://www.bianceng.cn/Programming/csharp/200911/11864.htm
      

  2.   


    public delegate int TH_PlateIDCfg_DMA_DataCopy(IntPtr dst,IntPtr src, int nSize);
    public delegate int TH_PlateIDCfg_Check_DMA_Finished();
    [StructLayoutAttribute(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
    public struct TH_PlateIDCfg {
        public int nMinPlateWidth;
        public int nMaxPlateWidth;
        public int nMaxImageWidth;
        public int nMaxImageHeight;
        public byte bVertCompress;
        public byte bIsFieldImage;
        public byte bOutputSingleFrame;
        public byte bMovingImage;
        public byte bIsNight;
        public byte nImageFormat;
        [MarshalAsAttribute(UnmanagedType.LPStr)]
        public string pFastMemory;
        public int nFastMemorySize;
        [MarshalAsAttribute(UnmanagedType.LPStr)]
        public string pMemory;
        public int nMemorySize;
        public TH_PlateIDCfg_DMA_DataCopy AnonymousMember1;
        public TH_PlateIDCfg_Check_DMA_Finished AnonymousMember2;
        public int nLastError;
        public int nErrorModelSN;
        [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst=120)]
        public string reserved;
    }
    public delegate int DMA_DataCopy(IntPtr dst,IntPtr src, int nSize);
    public delegate int Check_DMA_Finished();
    试下看成不
      

  3.   

    错误 3 找不到类型或命名空间名称“TH_PlateIDCfg_DMA_DataCopy”(是否缺少 using 指令或程序集引用?) E:\c#work\identify\id_test1\id_test1\Class_Struct.cs 102 20 id_test1
    这个声明应该放在哪里?
      

  4.   

    另:StructLayoutAttribute(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
    这行为什么报:错误 5 命名空间并不直接包含诸如字段或方法之类的成员 E:\c#work\identify\id_test1\id_test1\Class_Struct.cs 79 10 id_test1
    已经包含了:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Runtime.InteropServices;