Skip to content

Instantly share code, notes, and snippets.

@xv
Last active January 7, 2024 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xv/5705e58aba998b2ef5ec8fcc5e2c2be8 to your computer and use it in GitHub Desktop.
Save xv/5705e58aba998b2ef5ec8fcc5e2c2be8 to your computer and use it in GitHub Desktop.
Common Win32 API macros.
public static byte LOBYTE(ushort a) =>
(byte)(a & 0xFF);
public static byte HIBYTE(ushort a) =>
(byte)((a >> 8) & 0xFF);
public static ushort HIWORD(uint a) =>
(ushort)((a >> 16) & 0xFFFF);
public static ushort LOWORD(uint a) =>
(ushort)(a & 0xFFFF);
public static ushort MAKEWORD(byte a, byte b) =>
(ushort)((a & 0xFF) | (b << 8));
public static int MAKELONG(ushort a, ushort b) =>
(a & 0xFFFF) | ((b & 0xFFFF) << 16);
public static UIntPtr MAKEWPARAM(ushort a, ushort b) =>
new UIntPtr((uint)MAKELONG(a, b));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment