Simon Mourier's Avatar
Simon Mourier's blog (1807 answers on StackOverflow) about Microsoft technologies C#, C/C++, .NET, WinRT, WinUI3, AOT, P/Invoke, COM, Interop, DirectX, Direct2D, Windows, ...
  • 🔎︎ Search
  • Categories
  • Archives
  • About Me
  • c#
  • interop

How to define MAPINAMEID structure in C# in 32/64-bit compatible way?

Apr 3, 2018 See the question and my original answer on StackOverflow

You can declare it like that:

[StructLayout(LayoutKind.Sequential)]
private struct MAPINAMEID
{
    public IntPtr lpguid;
    public uint ulKind;
    public IntPtr lpwstrName; // or lID
};

And use IntPtr 32-bit conversion to switch between lpwstrName and lId when needed (LONG and ULONG are 32-bit).

  • SmoBlog © 2010-2026 Simon Mourier. All rights reserved.
  • Privacy & Terms