예제 #1
0
        internal static int SafeStgCreateStorageEx(
            string pwcsName,          //Pointer to path of compound file to create
            int grfMode,              // Specifies the access mode for opening the storage object
            int stgfmt,               // Specifies the storage file format, 5 is DocFile
            int grfAttrs,             // Reserved; must be zero
            IntPtr pStgOptions,       // Pointer to STGOPTIONS, not marshalled, must use NULL.
            IntPtr reserved2,         // Reserved; must be null
            ref Guid riid,            // Specifies the GUID of the interface pointer
            out IStorage ppObjectOpen //Pointer to an interface pointer
            )
        {
            UnsafeNativeCompoundFileMethods.UnsafeNativeIStorage storage;
            int result;

            result = UnsafeNativeCompoundFileMethods.StgCreateStorageEx(
                pwcsName,
                grfMode,
                stgfmt,
                grfAttrs,
                pStgOptions,
                reserved2,
                ref riid,
                out storage);

            if (result == SafeNativeCompoundFileConstants.S_OK)
            {
                ppObjectOpen = new SafeIStorageImplementation(storage);
            }
            else
            {
                ppObjectOpen = null;
            }

            return(result);
        }