/// <summary>
/// Gets window class long pointer for hWnd
/// </summary>
/// <param name="hWnd">window handle</param>
/// <param name="nIndex">index number</param>
/// <returns>window class long</returns>
private static IntPtr getClassLongPtr(IntPtr hWnd, int nIndex)
{
try
{
if (IntPtr.Size > 4)
{
return(User32Interop.GetClassLongPtr64(hWnd, nIndex));
}
uint ret = User32Interop.GetClassLongPtr32(hWnd, nIndex);
return(new IntPtr((int)ret)); // without the cast, it may result in an overflow
}
catch
{
return(IntPtr.Zero);
}
}