Exemplo n.º 1
0
 /// <summary></summary>
 /// <param name="openMode">
 /// Represents flags that should be used when opening the file that contains the object identified by the moniker.
 /// </param>
 /// <param name="timeout">
 /// Indicates the amount of time (clock time in milliseconds) that the caller specified to complete the binding operation.
 /// </param>
 /// <param name="bindFlags">Flags that control aspects of moniker binding operations.</param>
 public static IBindCtx CreateBindCtx(STGM openMode = STGM.STGM_READWRITE, TimeSpan timeout = default, BIND_FLAGS bindFlags = 0)
 {
     Ole32.CreateBindCtx(0, out var ctx).ThrowIfFailed();
     if (openMode != STGM.STGM_READWRITE || timeout != TimeSpan.Zero || bindFlags != 0)
     {
         var opts = new BIND_OPTS {
             cbStruct = Marshal.SizeOf(typeof(BIND_OPTS)), grfMode = (int)openMode, dwTickCountDeadline = (int)timeout.TotalMilliseconds, grfFlags = (int)bindFlags
         };
         ctx.SetBindOptions(ref opts);
     }
     return(ctx);
 }
Exemplo n.º 2
0
 void CreateBindCtx(out IBindCtx pbc)
 {
     System.Runtime.InteropServices.ComTypes.BIND_OPTS bo = new System.Runtime.InteropServices.ComTypes.BIND_OPTS() {
         cbStruct = Marshal.SizeOf(typeof(System.Runtime.InteropServices.ComTypes.BIND_OPTS)),
         dwTickCountDeadline = 0,
         grfFlags = 0,
         grfMode = STGM_CREATE
     };
     try {
         PInvoke.CreateBindCtx(0, out pbc);
         pbc.SetBindOptions(ref bo);
         pbc.RegisterObjectParam(STR_FILE_SYS_BIND_DATA, (IFileSystemBindData)this);
     }
     catch {
         pbc = null;
         throw;
     }
 }
Exemplo n.º 3
0
 //------------------------------------------------------------------------------
 // Helpers
 //------------------------------------------------------------------------------
 public static COMTypes.IBindCtx CreateBindContext()
 {
     COMTypes.IBindCtx pbc;
     int hr = WIN32.CreateBindCtx(0, out pbc);
     if (0==hr)
         {
         COMTypes.BIND_OPTS opts = new COMTypes.BIND_OPTS();
         opts.cbStruct = Marshal.SizeOf(opts);
         opts.grfMode = (int)BIND.MAYBOTHERUSER;
         pbc.SetBindOptions(ref opts);
         return pbc;
         }
     else
         {
             Marshal.ThrowExceptionForHR(hr);
         return null;
         }
 }
Exemplo n.º 4
0
 public void SetBindOptions(ref System.Runtime.InteropServices.ComTypes.BIND_OPTS pbindopts)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public void GetBindOptions(ref System.Runtime.InteropServices.ComTypes.BIND_OPTS pbindopts)
 {
     pbindopts.grfMode |= 4096;
 }
Exemplo n.º 6
0
 public System.Runtime.InteropServices.ComTypes.BIND_OPTS GetBindOptions()
 {
     System.Runtime.InteropServices.ComTypes.BIND_OPTS ret = new System.Runtime.InteropServices.ComTypes.BIND_OPTS();
     _object.GetBindOptions(ref ret);
     return(ret);
 }
Exemplo n.º 7
0
 public void SetBindOptions([In] ref System.Runtime.InteropServices.ComTypes.BIND_OPTS pbindopts)
 {
     _object.SetBindOptions(ref pbindopts);
 }