What are pens for? Intptr

I read on IntPtr and read that it is used to represent a descriptor. What does it mean? I am sure this is a simple explanation, but the light just does not turn on at the moment.

+7
source share
2 answers

This usually refers to the handle of the operating system and is used internally. For example, in Windows Forms, IntPtr used to access the window's work handle (HWND).

Handles in the Windows API are used for many things - most of the resources associated with the operating system (files, sockets, windows, etc.) are displayed through a handle, which is actually a pointer. In managed code, this is stored in IntPtr .

At the same time, IntPtr also regularly used to store pointers in interaction scenarios, since it automatically resizes based on 32-bit or 64-bit code.

+6
source

A pen is an opaque pointer. This is the value (usually just the number that is indexed into an array) that the operating system provides the application to represent the internal object, rather than pointing to it with a pointer to the actual object. This applies to both security considerations and abstraction - this forces the application to use the descriptor only through the provided APIs.

+6
source

All Articles