Ok, I'll try to make the examples as specific as possible.
- Window procedure parameters.
Window messages come in the form of (HWND,UINT,WPARAM,LPARAM).
Take the WM_CREATE message:
The LPARAM parameter points to a CREATESTRUCT structure. In order to access that structure, a cast is necessary.
Code:
CREATESTRUCT *cs = (LPCREATESTRUCT)lParam;
- Any Windows API function which uses a long to hold parameter values (there's a ton).
Code:
struct mystrdata *mydata = (struct mystrdata*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
or
Code:
struct mystrdata* mydata = (struct mystrdata*)SendMessage(hwndList, LB_GETITEMDATA,index,0);
- Getting DLL exported functions.
Code:
typedef void (*somefn)(int);
somefn myfunction = (somefn)GetProcAddress(hMod,"somefn");
- socket functions.
Code:
struct sockaddr_in addr;
/* Fill addr with bind information */
bind(s,(struct sockaddr*)&addr,sizeof(addr));
or
Code:
struct binarystruct *data = malloc(sizeof(*data));
/* Fill data with useful information */
send(socket,(char*)data,sizeof(data),0);
- Any mathematical expression which requires a floating point value to be assigned to an integer.
Code:
float numberOfHours = 2.5f;
int numberOfMinutes = numberOfHours * 60;