Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between PBYTE and BYTE*?

Tags:

c++

Well as the windows datatypes say PBYTE is just a pointer to a BYTE so what is the difference in c++ between declaring a BYTE* and PBYTE ? Also what is the difference between PBYTE AND LPBYTE ? is L stands for LONG ?

like image 581
Daniel Eugen Avatar asked Feb 05 '26 20:02

Daniel Eugen


2 Answers

In naming conventions where PBYTE and BYTE are typedefs, PBYTE is a pointer to BYTE. So there is no meaningful difference between PBYTE and BYTE * (unless you declare more than one variable at a time.

So

PBYTE x, y;

declares two pointers but

BYTE *x, y;

declares x as a pointer, and y as a BYTE (it would be necessary to use an addition asterisk to make y a pointer.). This sort of thing is a common source of errors - albeit errors that are often quickly detected by a compiler when the variables are used as intended.

With implementations that support multiple pointer sizes (e.g. near, far, huge), LPBYTE sometimes means a far pointer. This is meaningless in standard C++ (one memory model). However, some older architectures (e.g. older IBM compatible PC) which had a segmented memory architecture, with different types memory provided by distinct types of chips, and different pointer types were needed to address them. Modern operating systems that do virtualisation abstract this sort of thing away.

like image 98
Rob Avatar answered Feb 07 '26 10:02

Rob


According to Windows data types page it is simple typedef BYTE *PBYTE,*LPBYTE;

Also you may found useful this page: windef.h.

like image 26
Victor Polevoy Avatar answered Feb 07 '26 10:02

Victor Polevoy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!