Microsoft.VisualStudio.Project.UnsafeNativeMethods.GlobalSize C# (CSharp) Method

GlobalSize() private method

private GlobalSize ( SafeGlobalAllocHandle h ) : UIntPtr
h SafeGlobalAllocHandle
return System.UIntPtr
        internal static extern UIntPtr GlobalSize(SafeGlobalAllocHandle h);

Usage Example

Esempio n. 1
0
        internal static IntPtr CopyHGlobal(IntPtr data)
        {
            IntPtr src    = UnsafeNativeMethods.GlobalLock(data);
            int    size   = UnsafeNativeMethods.GlobalSize(data);
            IntPtr ptr    = Marshal.AllocHGlobal(size);
            IntPtr buffer = UnsafeNativeMethods.GlobalLock(ptr);

            try
            {
                for (int i = 0; i < size; i++)
                {
                    byte val = Marshal.ReadByte(new IntPtr((long)src + i));

                    Marshal.WriteByte(new IntPtr((long)buffer + i), val);
                }
            }
            finally
            {
                if (buffer != IntPtr.Zero)
                {
                    UnsafeNativeMethods.GlobalUnLock(buffer);
                }

                if (src != IntPtr.Zero)
                {
                    UnsafeNativeMethods.GlobalUnLock(src);
                }
            }
            return(ptr);
        }
All Usage Examples Of Microsoft.VisualStudio.Project.UnsafeNativeMethods::GlobalSize