Understanding the Definition of MAKEINTRESOURCEW

Looking at the Windows SDK, I found this #define directive for MAKEINTRESOURCEW:

#define MAKEINTRESOURCEW(i) ((LPWSTR)((ULONG_PTR)((WORD)(i))))

Can someone explain to me what this means? For example, what will be the value of MAKEINTRESOURCEW (0)? (1)? (-1)?

+3
source share
4 answers

The result of this macro will be a pointer to a long string with a value equal to the given parameter. You can see this by reading the output of the precompiler (see / P C ++ Compiler Options). All casting is required to compile this macro result when the W [W] WSTR pointer is required, both in Win32 and x64 configurations.

API Windows, LoadIcon, . , , , , ( C). , WORD .

+2

, int , , . int , , . , , ULONG_PTR "ULONG POINTER", - , , . 64- , :

#define MAKEINTRESOURCE(i)  (LPTSTR) ((DWORD) ((WORD) (i)))

ULONG_PTR, 32- 32- 64- 64- .

+2

, , unsigned long, .

+1

, " ".

: Windows 3.0 . , , . , , , , (, "" ).

" ", LPCTSTR ( ), .

Another example from the Windows API: a pointer to a window procedure. Each window has a window procedure (accessed GetWindowLongwith a flag GWL_WNDPROC. However, sometimes it’s just an integer that indicates what the β€œview” of the window is. Then there is a CallWindowProcthat knows to distinguish between these cases.

+1
source

Source: https://habr.com/ru/post/1748279/


All Articles