Casting in C++ does not change anything, it just tells the compiler that the basic type or pointer that you have defined will actually be used to point to something else. It is your responsibility to know what you are doing. Windows messages pass pointers in the WPARAM or LPARAM fields, and you need to cast them to the correct type before you can access the structure that they point to. In your case above, you cast the lParam item to the generic PDEV_BROADCAST_HDR so you can find out what type it is, and then you cast that pointer to the specific structure pointer as defined in the header.
One of these days I'm going to think of a really clever signature.
Thanks, you helped me to realize that the "orignal" lParam PDEV_BROADCAST_HDR structure contains the PDEV_BROADCAST_DEVICEINTERFACE structure. So the cast did not point to anything unknown. I missed that. Thanks
Yeah, you often get neted structs in Windows, with a base type at the start and other structs after that in memory, so there is lots of casting rom one type to another whcih is just to access the 'extended' data.
Nothing to say.
Last Visit: 31-Dec-99 19:00 Last Update: 3-May-15 1:37