Example #1
0
            /// <include file='doc\SafeNativeMethods.uex' path='docs/doc[@for="SafeNativeMethods.EnumVariant.Advance"]/*' />
            /// <devdoc>
            /// Moves the pointer to the next value In the contained IEnumVariant, and
            /// stores the current value In currentValue.
            /// </devdoc>
            private void Advance()
            {
                _currentValue = s_noMoreValues;
                IntPtr addr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Variant)));

                try
                {
                    int[] numRead = new int[] { 0 };
                    SafeNativeMethods.VariantInit(addr);
                    _enumerator.Next(1, addr, numRead);

                    try
                    {
                        if (numRead[0] > 0)
                        {
#pragma warning disable 612, 618
                            _currentValue = Marshal.GetObjectForNativeVariant(addr);
#pragma warning restore 612, 618
                        }
                    }
                    finally
                    {
                        SafeNativeMethods.VariantClear(addr);
                    }
                }
                finally
                {
                    Marshal.FreeCoTaskMem(addr);
                }
            }
Example #2
0
            private void Advance()
            {
                this.currentValue = NoMoreValues;
                IntPtr pObject = Marshal.AllocCoTaskMem(0x10);

                try
                {
                    int[] pceltFetched = new int[1];
                    SafeNativeMethods.VariantInit(pObject);
                    this.enumerator.Next(1, pObject, pceltFetched);
                    try
                    {
                        if (pceltFetched[0] > 0)
                        {
                            this.currentValue = Marshal.GetObjectForNativeVariant(pObject);
                        }
                    }
                    finally
                    {
                        SafeNativeMethods.VariantClear(pObject);
                    }
                }
                finally
                {
                    Marshal.FreeCoTaskMem(pObject);
                }
            }
            /// <include file='doc\SafeNativeMethods.uex' path='docs/doc[@for="SafeNativeMethods.EnumVariant.Advance"]/*' />
            /// <devdoc>
            /// Moves the pointer to the next value In the contained IEnumVariant, and
            /// stores the current value In currentValue.
            /// </devdoc>
            private void Advance()
            {
                currentValue = NoMoreValues;
                IntPtr addr = Marshal.AllocCoTaskMem(16 /*Marshal.SizeOf(typeof(VARIANT))*/);

                try {
                    int[] numRead = new int[] { 0 };
                    SafeNativeMethods.VariantInit(addr);
                    enumerator.Next(1, addr, numRead);
                    try {
                        if (numRead[0] > 0)
                        {
                            currentValue = Marshal.GetObjectForNativeVariant(addr);
                        }
                    }
                    finally {
                        SafeNativeMethods.VariantClear(addr);
                    }
                }
                finally {
                    Marshal.FreeCoTaskMem(addr);
                }
            }