Home c++ C++ lpvoid pchar What are their purpose?

C++ lpvoid pchar What are their purpose?

Author

Date

Category

C++ has basic data types.

int string char void dword param

But why do such data types need?

lparam lpvoid pchar lpcvoid lpdword WPARAM

How are they used?
What is the actual purpose?


Answer 1, Authority 100%

Let’s start with the basic data types in C++:

Int String Char Void Dword Param

STD :: STRING is not the main type, and is a specialization of the template STD :: Basic_String from the standard library, which, in turn, is not a basic type. DWORD is not C++ type in general. Param I think this is, did you mistaken, so? In addition to these types, C++ has even quite a few others. Read the C++ book, learn a lot.

As for other types:

lparam lpvoid pchar lpcvoid lpdword WPARAM

are pseudonym types, i.e. These are some basic types that other names were given. For example, I can enter a new name for int :

typedef int superbtype;

And everywhere use SuperBType instead of int . Why do it? For convenience – the name of the types more correspond to the scope of their application, and also carry some additional information. So, for example, DWORD means a double word, which tells us that this type will always be equal to 4th bytes. The corresponding TypeDef guarantees us for both 32-bit and 16-bit systems (WinAPI is an old technology). To see what is really hiding behind the names of these types, you can in WinAPI headers.


Answer 2, Authority 33%

lparam lpvoid pchar lpcvoid lpdword WPARAM

is all the aliases of the standard types used by Microsoft in WinAPI . They are introduced so that their size always corresponds to the desired (since the length of the entire types in C / C++ is not fixed), as well as to improve readability and understanding (although this improvement is still a big question …).

For example, for x86, these types are as follows:

typeedef long long_ptr;
TypeDef void * lpvoid;
TypeDef char * pchar;
TypeDef Const void * lpcvoid;
Typedef unsigned long * lpdword;
TypeDef unsigned int wparam;

More information on the site M $ .


Answer 3, Authority 33%

In addition to other answers:

lparam and WParam are commonly used in the context of windowproc window procedures. These are the procedures that are “attached” to each window and process messages that the system (or other processes) sends this window. For example, messages about mouse movement or size change.

The procedure is defined as:

Lresult Callback WindowProc (
 _In_ hwnd hwnd,
 _In_ uint umsg,
 _In_ WParam WParam,
 _In_ lparam lparam
);

and takes hwnd – handle windows, uint -prameter (number window message ), and two arguments, one of which is a number (usually a small numeric parameter, some flags etc.), and the second is a long number (for example, a pair of numbers, coordinates) or a pointer (on the buffer). The exact meaning of the parameters depends on the type of message.

All this makes sense only in WinAPI programming (low-level programming under Windows Desktop). Modern systems / frameworks usually provide you with higher-level abstractions. (For example, the class cwnd together handle hwnd in MFC.)

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions