This is for backward compatibility when Windows API is extended.
Imagine the following declarations
struct WinData
{
long flags;
}
BOOL GetWinData(WinData * wd);
which you are calling like this:
WinData wd;
GetWinData(&wd);
A future OS version may extend this to
struct WinData
{
long flags;
long extraData;
}
However, if you have compiled against the "older" SDK, GetWinData
has no chance to figure out you don't know about extraData
. If it would fill it in regardless, it would overwrite data on the stack. BOOOM!
That's why, the "size known to the caller" is added to the structure, and new members are appended at the end. The GetWinData
implementation can inspect the size and decide "this poor guy doesn't know about all the new features yet".