Ejemplo n.º 1
0
        private static void TestAllocString_IntPtrString()
        {
            MsEmployee_IntPtrString employee = new MsEmployee_IntPtrString();
            employee.EmployeeID = 10001;
            GetEmployeeInfo_IntPtrString(ref employee);

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

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

            Console.WriteLine("\nԱ����Ϣ:");
            Console.WriteLine("ID: {0}", employee.EmployeeID);
            Console.WriteLine("����:{0}", employee.EmployedYear);
            Console.WriteLine("Alias: {0}", alias);
            Console.WriteLine("����: {0}", displayName);
        }
Ejemplo n.º 2
0
 private static extern void GetEmployeeInfo_IntPtrString(ref MsEmployee_IntPtrString employee);