Skip to content

Instantly share code, notes, and snippets.

@kant2002
Created August 10, 2022 06:33
Show Gist options
  • Save kant2002/07cf7ec06391e92a0d67409665fc0d14 to your computer and use it in GitHub Desktop.
Save kant2002/07cf7ec06391e92a0d67409665fc0d14 to your computer and use it in GitHub Desktop.
LibraryImport Generator sample
[LibraryImport(Libraries.UxTheme)]
public static partial HRESULT DrawThemeEdge(
IntPtr hTheme,
Gdi32.HDC hdc,
int iPartId,
int iStateId,
ref RECT pDestRect,
User32.EDGE uEdge,
User32.BF uFlags,
ref RECT pContentRect);
internal static unsafe partial class Interop
{
public static unsafe partial class UxTheme
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "7.0.6.40809")]
[System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial global::Interop.HRESULT DrawThemeEdge(nint hTheme, global::Interop.Gdi32.HDC hdc, int iPartId, int iStateId, ref global::Interop.RECT pDestRect, global::Interop.User32.EDGE uEdge, global::Interop.User32.BF uFlags, ref global::Interop.RECT pContentRect)
{
global::Interop.HRESULT __retVal;
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.RECT* __pDestRect_native = &pDestRect)
fixed (global::Interop.RECT* __pContentRect_native = &pContentRect)
{
__retVal = __PInvoke(hTheme, hdc, iPartId, iStateId, __pDestRect_native, uEdge, uFlags, __pContentRect_native);
}
return __retVal;
// Local P/Invoke
[System.Runtime.InteropServices.DllImportAttribute("uxtheme.dll", EntryPoint = "DrawThemeEdge", ExactSpelling = true)]
static extern unsafe global::Interop.HRESULT __PInvoke(nint hTheme, global::Interop.Gdi32.HDC hdc, int iPartId, int iStateId, global::Interop.RECT* pDestRect, global::Interop.User32.EDGE uEdge, global::Interop.User32.BF uFlags, global::Interop.RECT* pContentRect);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment