mirror of https://github.com/dahall/Vanara.git
Fixed bugs in the storage and reading of integer resource identifiers.
parent
3553f76034
commit
fd97276a2c
|
@ -331,11 +331,7 @@ namespace Vanara.PInvoke
|
|||
|
||||
/// <summary>Initializes a new instance of the <see cref="SafeResourceId"/> class.</summary>
|
||||
/// <param name="resId">The resource identifier.</param>
|
||||
public SafeResourceId(int resId)
|
||||
{
|
||||
if (resId > ushort.MaxValue || resId <= 0) throw new ArgumentOutOfRangeException(nameof(resId));
|
||||
SetHandle((IntPtr)(ushort)resId);
|
||||
}
|
||||
public SafeResourceId(int resId) => id = resId;
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="SafeResourceId"/> class.</summary>
|
||||
/// <param name="resType">Type of the resource.</param>
|
||||
|
@ -371,9 +367,9 @@ namespace Vanara.PInvoke
|
|||
get => IsIntResource ? (ushort)handle.ToInt32() : 0;
|
||||
set
|
||||
{
|
||||
if (value > ushort.MaxValue || value <= 0) throw new ArgumentOutOfRangeException(nameof(id));
|
||||
if (value > short.MaxValue || value < short.MinValue) throw new ArgumentOutOfRangeException(nameof(id));
|
||||
InternalCloseMethod(handle);
|
||||
SetHandle((IntPtr)(ushort)value);
|
||||
SetHandle((IntPtr)unchecked((ushort)value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace Vanara.PInvoke
|
|||
/// <param name="ptr">The pointer to be tested whether it contains an integer resource identifier.</param>
|
||||
/// <returns>If the value is a resource identifier, the return value is TRUE. Otherwise, the return value is FALSE.</returns>
|
||||
[PInvokeData("WinBase.h", MSDNShortId = "ms648028")]
|
||||
public static bool IS_INTRESOURCE(IntPtr ptr) => ptr.ToInt64() >> 16 == 0;
|
||||
public static bool IS_INTRESOURCE(IntPtr ptr) => unchecked((ulong)ptr.ToInt64()) >> 16 == 0;
|
||||
|
||||
/// <summary>Retrieves the low-order byte from the given 16-bit value.</summary>
|
||||
/// <param name="wValue">The value to be converted.</param>
|
||||
|
|
Loading…
Reference in New Issue