日期:2014-05-17  浏览次数:21291 次

才疏学浅,求助,C#调用C++ dll 返回结构体数组指针
//C++中定义:
struct GPS_TAXI_DATA
{
int id;
int equip_id;
double cross_x;
double cross_y;
string gps_date;
double speed;
int direct;
int status;
int acc;
string rece_date;
};


_declspec(dllimport) GPS_TAXI_DATA * get_gps_data(int year,int month,int day,int hour,int min,int sec,int &GPS_Arry_Num);


C#中:
        
[StructLayout(LayoutKind.Sequential)]
        public struct GPS_TAXI_DATA
        {
            [MarshalAs(UnmanagedType.I4)]
            int id;
            [MarshalAs(UnmanagedType.I4)]
            int equip_id;
            [MarshalAs(UnmanagedType.I8)]
            double cross_x;
            [MarshalAs(UnmanagedType.I8)]
            double cross_y;
            [MarshalAs(UnmanagedType.LPStr)]
            string gps_date;
            [MarshalAs(UnmanagedType.I8)]
            double speed;
            [MarshalAs(UnmanagedType.I4)]
            int direct;
            [MarshalAs(UnmanagedType.I4)]
            int status;
            [MarshalAs(UnmanagedType.I4)]
            int acc;
            [MarshalAs(UnmanagedType.LPStr)]
            string rece_date;
        };




        [DllImport(@"C:\Documents and Settings\jiangbinze\桌面\test\test.dll", EntryPoint = "get_gps_data")]