   A simple Win32 question?
  The WINCLASSEX struct has a member called cbSize which is the size of the structure. Why do we have to tell the structure its size?   
WNDCLASSEX WndClassEx;WndClassEx.cbSize = sizeof(WNDCLASSEX);[edit] - Sorry I read too fast :)A lot of the Microsoft stuctures do this.  I think this is kind of a weird form of versioning in their code behind the scenes.  I think it also is because most structures are passed by pointer, so it is hard to tell what was actually passed and how big it really is.[Edited by - Rattrap on February 12, 2010 8:36:05 AM];  Thanks :)   ;Quote:Original post by RattrapI think this is kind of a weird form of versioning in their code behind the scenes.  Yes this is exactly it. The functions uses it to know which version of the Windows SDK the program was compiled with, so that it knows what behavior to use. This way when Microsoft adds new functionality to a function they can make the struct bigger, and older programs using smaller struct size will get the behavior they expect (which keeps them from crashing).;  There's nothing particularly wierd about it.  API's evolve over time.  Microsoft wants to be able to do that without having to create a new version of the API every single time.  Introducing new API's also makes it harder for developers to adopt them because their programs won't work at all on older systems without special care.  Having a size field is in some ways simpler than a version field and it's easy/effiecient to get the size so why not.WNDCLASSEX is actually an excellent example.  If the original structure (WNDCLASS) had had the size field they wouldn't have had to create the RegisterClassEx API.  Programs would just set the size to whatever they knew about and call the single API.   