// THIS FILE IS PART OF Vanara PROJECT // THE Vanara PROJECT IS AN OPENSOURCE LIBRARY LICENSED UNDER THE MIT License. // COPYRIGHT (C) dahall. ALL RIGHTS RESERVED. // GITHUB: https://github.com/dahall/Vanara using System; namespace Vanara.PInvoke { /// Platform invokable enumerated types, constants and functions from windows.h public static partial class Macros { /// Determines whether a value is an integer identifier for a resource. /// The pointer to be tested whether it contains an integer resource identifier. /// If the value is a resource identifier, the return value is TRUE. Otherwise, the return value is FALSE. [PInvokeData("WinBase.h", MSDNShortId = "ms648028")] public static bool IS_INTRESOURCE(IntPtr ptr) => unchecked((ulong)ptr.ToInt64()) >> 16 == 0; /// Retrieves the low-order byte from the given 16-bit value. /// The value to be converted. /// The return value is the low-order byte of the specified value. public static byte LOBYTE(ushort wValue) => (byte)(wValue & 0xff); /// Gets the lower 8-bytes from a value. /// The value. /// The lower 8-bytes as a . public static uint LowPart(this long lValue) => (uint)(lValue & 0xffffffff); /// Retrieves the low-order word from the specified 32-bit value. /// The value to be converted. /// The return value is the low-order word of the specified value. public static ushort LOWORD(uint dwValue) => (ushort)(dwValue & 0xffff); /// Retrieves the low-order word from the specified 32-bit value. /// The value to be converted. /// The return value is the low-order word of the specified value. public static ushort LOWORD(IntPtr dwValue) => unchecked((ushort)(long)dwValue); /// Retrieves the low-order word from the specified 32-bit value. /// The value to be converted. /// The return value is the low-order word of the specified value. public static ushort LOWORD(UIntPtr dwValue) => unchecked((ushort)(ulong)dwValue); /// /// Converts an integer value to a resource type compatible with the resource-management functions. This macro is used in place of a /// string containing the name of the resource. /// /// The integer value to be converted. /// The return value is string representation of the integer value. [PInvokeData("WinUser.h", MSDNShortId = "ms648029")] public static ResourceId MAKEINTRESOURCE(int id) => id; /// Creates a LONG value by concatenating the specified values. /// The low-order word of the new value. /// The high-order word of the new value. /// The return value is a LONG value. public static int MAKELONG(int wLow, int wHigh) => (wHigh << 16) | (wLow & 0xffff); /// Creates a LONG64 value by concatenating the specified values. /// The low-order double word of the new value. /// The high-order double word of the new value. /// The return value is a LONG64 value. public static long MAKELONG64(long dwLow, long dwHigh) => (dwHigh << 32) | (dwLow & 0xffffffff); /// Creates a value for use as an lParam parameter in a message. The macro concatenates the specified values. /// The low-order word of the new value. /// The high-order word of the new value. /// The return value is an LPARAM value. public static IntPtr MAKELPARAM(int wLow, int wHigh) => new IntPtr(MAKELONG(wLow, wHigh)); } }