当前位置:编程学习 > C#/ASP.NET >>

c#调用c++ 指针参数 急~~~~~在线等

int CVR_Scan (int ScanType,int ScanMode, int iDirect,IDCARD_ALL *PIDCARD);
 IDCARD_ALL *PIDCARD这是神马类型 没有见过啊 
下面的是我自己写的定义结构


        public struct IDCARD_ALL
        {
            string name; //姓名
            string SurnameCH; //中文姓
            string nameCH; //中文名
            string sex; //性别
            string Gender; //性别(英文)
            string birthday; //出生日期
            string people; //民族
            string signdate; //发证日期
            string validterm; //有效期限
            string address; //地址
            string number; //身份证号码
            string organs; //发证机关
            string SurnameEN; //英文姓(汉语拼音)
            string nameEN; //英文名(汉语拼音)
            string ENfullname; //英文姓名
            string Nationality; //国籍
            string id; //证件号码
            string Leavetime; //离开时间
            string placeCH; //签发地点中文
            string placeEN; //签发地点英文
            string BirthplaceCH; //出生地中文 
            string BirthplaceEN; //出生地英文
            string szCodeOne; //第一行代码识别结果
            string szCodeTwo; //第二行代码识别结果
            string szCodeThree; //第三行代码识别结果
            string Permitnumber_number; //港澳证件号码
            string Vocational; //职业
            string DocumentsCategory; //证件类别
            string Other;

        }


我怎么样可以CVR_Scan (0,1, 0, PIDCARD);这样调用呢 --------------------编程问答-------------------- ref IDCARD_ALL 
或者
使用unsafe,可以使用指针 --------------------编程问答-------------------- Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public struct XRgn32F
    {
        public IntPtr v;
        public int iV;
        public float X;
        public float Y;
        public float W;
        public float H;
        public float A;
        public int T;
        public int M;
        public int flag;
        public int color;



        public void Init(XRegion rgn)
        {
            iV = rgn.m_Points.Length;
            v = XMemory.malloc(iV * 8);
            RectangleF rect = rgn.GetRectangle();
            X = rect.Left;
            Y = rect.Top;
            W = rect.Width;
            H = rect.Height;
            A = rgn.R;
            //M = rgn.M?1:0 ;
            //T = rgn.T?1:0 ;
            XImgPro.SetPointsFromArray(v, iV, rgn.m_Points);
        }

        public void Free()
        {
            XMemory.free(v);
        } --------------------编程问答-------------------- 记得好像是这样封装的,需要为string分配长度:

        [StructLayout( LayoutKind.Sequential)]
        public struct IDCARD_ALL
        {
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
            string name;        //姓名
            //......
        }
--------------------编程问答-------------------- 1楼基本都说清楚了,
两种方式都可以:
[DllImport("xx.dll",EntryPoint="CVR_Scan",CallingConvention =CallingConvention.Cdecl,CharSet=CharSet.Ansi)]
public static extern int CVR_Scan (int ScanType,int ScanMode, int iDirect,ref IDCARD_ALL PIDCARD);

或者:

[DllImport("xx.dll",EntryPoint="CVR_Scan",CallingConvention =CallingConvention.Cdecl,CharSet=CharSet.Ansi)]
public static extern int CVR_Scan (int ScanType,int ScanMode, int iDirect,IntPtr PIDCARD); --------------------编程问答-------------------- 用stringbuilder类型就可以了。
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,