示例#1
0
        private static void StructAllocString_IntPtrString()
        {
            MsEmployee_IntPtrString employee = new MsEmployee_IntPtrString();

            employee.EmployeeID = 10001;
            CPlusPlusLib.GetEmployeeInfoA(ref employee);

            string displayName = Marshal.PtrToStringAnsi(employee.DisplayName);
            string alias       = Marshal.PtrToStringAnsi(employee.Alias);

            Marshal.FreeCoTaskMem(employee.DisplayName);
            Marshal.FreeCoTaskMem(employee.Alias);

            Console.WriteLine("\nemployee Info IntPtrString:");
            Console.WriteLine("ID: {0}", employee.EmployeeID);
            Console.WriteLine("Year:{0}", employee.EmployedYear);
            Console.WriteLine("Alias: {0}", alias);
            Console.WriteLine("Name: {0}", displayName);
        }
示例#2
0
 public extern static void GetEmployeeInfoA(ref MsEmployee_IntPtrString ppStruct);