예제 #1
0
 private static extern int StgCreateStorageEx(
     [MarshalAs(UnmanagedType.LPWStr)] string name,
     STGM accessMode,
     STGFMT storageFileFormat,
     int fileBuffering,
     IntPtr options,
     IntPtr reserved,
     [In, MarshalAs(UnmanagedType.LPStruct)] System.Guid riid,
     [In, Out, MarshalAs(UnmanagedType.Interface)] ref myIStorage propertySetStorage);
예제 #2
0
        // Not used - But there are things here that may be useful some day
#if false
        void TestSave2()
        {
            int         hr;
            UCOMIStream uis = null;
            long        siz;

            hr = m_ips.GetSizeMax(out siz);
            myIStorage iStore = null;

            hr = StgCreateDocfile(@"C:\foo.out",
                                  //STGM.DIRECT|STGM.CREATE|STGM.READWRITE|STGM.SHARE_EXCLUSIVE,
                                  STGM.CREATE | STGM.WRITE | STGM.SHARE_EXCLUSIVE,
                                  0,
                                  ref iStore);
            DsError.ThrowExceptionForHR(hr);
            uis = iStore as UCOMIStream;

            //hr = iStore.CreateStream("asdf", STGM.DIRECT|STGM.CREATE|STGM.READWRITE|STGM.SHARE_EXCLUSIVE, 0, 0, out uis);
            hr = iStore.CreateStream("asdf", STGM.CREATE | STGM.WRITE | STGM.SHARE_EXCLUSIVE, 0, 0, out uis);

            hr = OleSaveToStream(m_ips, uis);

            hr = StgCreateStorageEx(@"c:\foo.out",
                                    (STGM)0,
                                    (STGFMT)0,
                                    0,
                                    IntPtr.Zero,
                                    IntPtr.Zero,
                                    typeof(myIStorage).GUID,
                                    ref iStore);
            DsError.ThrowExceptionForHR(hr);

            string s = typeof(UCOMIStream).GUID.ToString();

            // Create the stream (with no initial memory allocated)
            IntPtr ip = Marshal.AllocCoTaskMem((int)siz);

            ip = GlobalAlloc(0, (int)siz);
            hr = CreateStreamOnHGlobal(ip, false, out uis);
            //uis.SetSize(siz * 2);

            byte[] b = new byte[3];
            b[0] = 65;
            b[1] = 66;
            b[2] = 67;

            uis.Write(b, b.Length, IntPtr.Zero);

            hr = m_ips.Save(uis, true);
            DsError.ThrowExceptionForHR(hr);
        }
예제 #3
0
 private static extern int StgCreateDocfile(
     [MarshalAs(UnmanagedType.LPWStr)] string name,
     STGM grfMode,
     int reserved,
     [In, Out, MarshalAs(UnmanagedType.Interface)] ref myIStorage propertySetStorage
     );