How to use GetWindowLongPtr() in win10

凯 唐 1 Reputation point
2021-11-11T08:14:09.707+00:00

In Windows 10 64bit OS, when I need to get a windows style, I should use GetWindowLongPtr(this->m_hWnd, GWL_STYLE); or GetWindowLong(this->m_hWnd, GW_STYLE);?

I tried both of them, the results are both OK. But I want to know which one is better?

Thanks!

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,412 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 81,461 Reputation points
    2021-11-11T08:37:46.27+00:00

    It is explained in the Note of the API :

    Note
    To write code that is compatible with both 32-bit and 64-bit versions of Windows, use GetWindowLongPtr. When compiling for 32-bit Windows, GetWindowLongPtr is defined as a call to the GetWindowLong function.

    1 person found this answer helpful.