Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Win32, what does the size member (cb) name actually mean?

Tags:

c

winapi

In quite a few Win32 structures you have to give the size of the structure to one of its members, in quite a few cases, the member that stores this is called cb or prefixed with this.

DISPLAY_DEVICE has a cb member for size.

It's also used in names of certain types of messages, such as CB_GETCURSEL. Perhaps in this case its for ComboBox.

In other places in Win32, the cb acronym (I assume?) is used as part of member names.

Such as WNDCLASS which have cbWndExtra and cbClsExtra.

In STARTUPINFO you have it:

typedef struct _STARTUPINFO {
  DWORD  cb;
  LPTSTR lpReserved;
  LPTSTR lpDesktop;
  LPTSTR lpTitle;
  DWORD  dwX;
  DWORD  dwY;
  DWORD  dwXSize;
  DWORD  dwYSize;
  DWORD  dwXCountChars;
  DWORD  dwYCountChars;
  DWORD  dwFillAttribute;
  DWORD  dwFlags;
  WORD   wShowWindow;
  WORD   cbReserved2;
  LPBYTE lpReserved2;
  HANDLE hStdInput;
  HANDLE hStdOutput;
  HANDLE hStdError;
} STARTUPINFO, *LPSTARTUPINFO;

The documentation says this:

cb

The size of the structure, in bytes.

I wondered if anyone knows what cb stands for or means? If it does have meaning at all.

Perhaps someone knows the history of this, which may explain it.

like image 892
Tony The Lion Avatar asked Aug 18 '13 11:08

Tony The Lion


2 Answers

It probably stands for count bytes.

For example in the STARTUPINFO it should be initialized by you to sizeof(STARTUPINFO). That way, the Windows internals will know which version of the struct you are using, as it has grown over the time.

In the other cases is simply a number of bytes.

Except in the ComboBoxes, there it stands for Combo Box.

like image 85
rodrigo Avatar answered Sep 20 '22 11:09

rodrigo


cb in this case stands for

Count of bytes.

like image 40
tenfour Avatar answered Sep 22 '22 11:09

tenfour