How to use GetWindowLongPtr() in win10

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

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?


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.
1,890 questions
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2021-11-11T08:37:46.27+00:00
    Castorix31 65,366 Reputation points

    It is explained in the Note of the API :

    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.