mirror of https://github.com/dahall/Vanara.git
Add ContextSwitcher and other IIDs. Fix IContextCallback. (#211)
Co-authored-by: Konstantin Sharon <NN---@users.noreply.github.com>pull/213/head
parent
c703c450f9
commit
f45861e1e1
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Vanara.PInvoke
|
||||
|
@ -49,7 +50,12 @@ namespace Vanara.PInvoke
|
|||
/// </remarks>
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/ctxtcall/nf-ctxtcall-icontextcallback-contextcallback
|
||||
[PreserveSig]
|
||||
HRESULT ContextCallback(PFNCONTEXTCALL pfnCallback, in ComCallData pParam, in Guid riid, int iMethod, [In, Optional] IntPtr pUnk);
|
||||
HRESULT ContextCallback(
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] PFNCONTEXTCALL pfnCallback,
|
||||
in ComCallData pParam,
|
||||
in Guid riid,
|
||||
int iMethod,
|
||||
[In, Optional] IntPtr pUnk);
|
||||
}
|
||||
|
||||
/// <summary/>
|
||||
|
@ -66,5 +72,30 @@ namespace Vanara.PInvoke
|
|||
/// <summary/>
|
||||
public IntPtr pUserDefined;
|
||||
}
|
||||
|
||||
/// <summary>Provides a mechanism to execute a function inside a specific COM+ object context.</summary>
|
||||
/// <remarks>An instance of this interface for the current context can be obtained using CoGetObjectContext.</remarks>
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/ctxtcall/nn-ctxtcall-icontextcallback
|
||||
[ComImport, Guid("0000034e-0000-0000-C000-000000000046"), ClassInterface(ClassInterfaceType.None)]
|
||||
public class ContextSwitcher : IContextCallback
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
|
||||
public virtual extern HRESULT ContextCallback(
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] PFNCONTEXTCALL pfnCallback,
|
||||
in ComCallData pParam,
|
||||
in Guid riid,
|
||||
int iMethod,
|
||||
IntPtr pUnk = new IntPtr());
|
||||
}
|
||||
|
||||
/// <summary>CLSID_ContextSwitcher</summary>
|
||||
public static readonly Guid CLSID_ContextSwitcher = new Guid(0x0000034e, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
|
||||
|
||||
/// <summary>IID_IEnterActivityWithNoLock</summary>
|
||||
public static readonly Guid IID_IEnterActivityWithNoLock = new Guid(0xd7174f82, 0x36b8, 0x4aa8, 0x80, 0x0a, 0xe9, 0x63, 0xab, 0x2d, 0xfa, 0xb9);
|
||||
|
||||
/// <summary>IID_ICallbackWithNoReentrancyToApplicationSTA</summary>
|
||||
public static readonly Guid IID_ICallbackWithNoReentrancyToApplicationSTA = new Guid(0x0a299774, 0x3e4e, 0xfc42, 0x1d, 0x9d, 0x72, 0xce, 0xe1, 0x05, 0xca, 0x57);
|
||||
}
|
||||
}
|
|
@ -95,5 +95,12 @@ namespace Vanara.PInvoke.Tests
|
|||
Assert.That(prvRead[0].Value, Is.EqualTo("VALUE"));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ContextSwitcher()
|
||||
{
|
||||
Assert.AreEqual(CLSID_ContextSwitcher, typeof(ContextSwitcher).GUID);
|
||||
IContextCallback contextCallback = new ContextSwitcher();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue