private static extern Boolean GetVersionEx_Val_NonBlit(ref OSVersionInfoEx_Val_NonBlit versionInfo);
        public void PerfTest(Int32 testIterations)
        {
            Console.WriteLine("Test Iteration for each type: {0}", testIterations);
            // 1. Non-blittable reference type
            // Start with a fresh managed heap
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            // Start time
            DateTime start = DateTime.Now;

            // Create the marshalled instance and perform calls
            OSVersionInfoEx_Ref_NonBlit info_ref_nonblit = new OSVersionInfoEx_Ref_NonBlit();
            for (Int32 index = 0; index < testIterations; index++)
            {
                // We will not user wrapper method so that we can test on pure performance
                // WrapperGetVersionEx_Ref_NonBlit(info_ref_nonblit);
                GetVersionEx_Ref_NonBlit(info_ref_nonblit);
            }

            // End time
            TimeSpan span = DateTime.Now - start;

            // Output results
            Console.WriteLine("Non-blittable reference type marshalling took: \t{0} secs", span.TotalSeconds);

            // 2. Blittalbe reference type
            // Start with a fresh managed heap
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            // Start time
            start = DateTime.Now;

            // Create the marshalled instance and perform calls
            OSVersionInfoEx_Ref_Blit info_ref_blit = new OSVersionInfoEx_Ref_Blit();
            for (Int32 index = 0; index < testIterations; index++)
            {
                // We will not user wrapper method so that we can test on pure performance
                // WrapperGetVersionEx_Ref_Blit(info_ref_blit);
                GetVersionEx_Ref_Blit(info_ref_blit);
            }

            // End time
            span = DateTime.Now - start;

            // Output results
            Console.WriteLine("Blittable reference type marshalling took: \t{0} secs", span.TotalSeconds);

            // 3. Non-blittalbe value type
            // Start with a fresh managed heap
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            // Start time
            start = DateTime.Now;

            // Create the marshalled instance and perform calls
            OSVersionInfoEx_Val_NonBlit info_val_nonblit = new OSVersionInfoEx_Val_NonBlit();

            // If we use the wrapper method, the next statement is not necessary, since the wrapper method will do the stuff.
            info_val_nonblit.OSVersionInfoSize = (UInt32)Marshal.SizeOf(typeof(OSVersionInfoEx_Val_NonBlit));
            for (Int32 index = 0; index < testIterations; index++)
            {
                // We will not user wrapper method so that we can test on pure performance
                // WrapperGetVersionEx_Val_NonBlit(out info_val_nonblit);
                GetVersionEx_Val_NonBlit(ref info_val_nonblit);
            }

            // End time
            span = DateTime.Now - start;

            // Output results
            Console.WriteLine("Non-blittable value type marshalling took : \t{0} secs", span.TotalSeconds);

            // 4. Blittalbe value type
            // Start with a fresh managed heap
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            // Start time
            start = DateTime.Now;

            // Create the marshalled instance and perform calls
            OSVersionInfoEx_Val_Blit info_val_blit = new OSVersionInfoEx_Val_Blit();

            // If we use the wrapper method, the next statement is not necessary, since the wrapper method will do the stuff.
            info_val_blit.OSVersionInfoSize = (UInt32)Marshal.SizeOf(typeof(OSVersionInfoEx_Val_Blit));
            for (Int32 index = 0; index < testIterations; index++)
            {
                // We will not user wrapper method so that we can test on pure performance
                // WrapperGetVersionEx_Val_Blit(out info_val_blit);
                GetVersionEx_Val_Blit(ref info_val_blit);
            }

            // End time
            span = DateTime.Now - start;

            // Output results
            Console.WriteLine("Blittable value type marshalling took : \t{0} secs", span.TotalSeconds);

            // Dump version info
            Console.WriteLine("{0}Current system version information:", Environment.NewLine);
            Console.WriteLine("OSVersionInfoSize: \t{0}", info_val_blit.OSVersionInfoSize);
            Console.WriteLine("MajorVersion: \t\t{0}", info_val_blit.MajorVersion);
            Console.WriteLine("MinorVersion: \t\t{0}", info_val_blit.MinorVersion);
            Console.WriteLine("BuildNumber: \t\t{0}", info_val_blit.BuildNumber);
            Console.WriteLine("PlatformId: \t\t{0}", info_val_blit.PlatformId);
            Console.WriteLine("CSDVersion: \t\t{0}", info_val_blit.CSDVersion);
            Console.WriteLine("ServicePackMajor: \t{0}", info_val_blit.ServicePackMajor);
            Console.WriteLine("ServicePackMinor: \t{0}", info_val_blit.ServicePackMinor);
            Console.WriteLine("SuiteMask: \t\t{0}", info_val_blit.SuiteMask);
            Console.WriteLine("ProductType: \t\t{0}", info_val_blit.ProductType);
            Console.WriteLine("Reserved: \t\t{0}", info_val_blit.Reserved);
            Console.WriteLine();
        }
 /// <summary>
 /// ���Ƕ�Win32 API����GetVersionEx���з�װ��İ�װ����
 /// </summary>
 /// <param name="type"></param>
 public void WrapperGetVersionEx_Val_NonBlit(out OSVersionInfoEx_Val_NonBlit versionInfo)
 {
     versionInfo = new OSVersionInfoEx_Val_NonBlit();
     versionInfo.OSVersionInfoSize = (UInt32)Marshal.SizeOf(typeof(OSVersionInfoEx_Val_NonBlit));
     if (!GetVersionEx_Val_NonBlit(ref versionInfo))
     {
         // ���ʧ�ܣ�������Ĵ����룬���׳���Ӧ��Win32�쳣
         Int32 err = Marshal.GetLastWin32Error();
         throw new Win32Exception(err);
     }
 }