public static IntPtr ReAllocCoTaskMem(IntPtr pv, int cb) { IntPtr pNewMem = Win32Native.CoTaskMemRealloc(pv, new UIntPtr((uint)cb)); if (pNewMem == IntPtr.Zero && cb != 0) { throw new OutOfMemoryException(); } return(pNewMem); }