RE: Damn Unions
- Posted by Don Phillips <Graebel at hotmail.com> Jul 26, 2002
- 402 views
Hey Jordah =) Dont sweat the details on this too hard. You have been working with unions all along (kinda), you just didnt know it. Heres a good example I hope will make since. wParam and lParam are 32 bit (DWORD) variables in memory. Most of the time you will use them whole (same as dwOemId). If however you are processing a WM_MOUSE or similar message, it is no longer a DWORD but two WORD's (x and y positions). This is a union. It can be accessed either by DWORD or 2 WORDS. In this case just declare that whole union as DWORD dwOemId. If you need the other two elements, peek4u it out into a Euphoria variable and use Win32Libs built in lo_word() / hi_word() to extract the parts you need... Don Phillips jordah ferguson wrote: > Hi All, > > Is there some one out there who can help me link this structure > to euphoria. My lack of understanding of what a union is has led to > this. > > typedef struct _SYSTEM_INFO { // sinf > > union { > DWORD dwOemId; > struct { > WORD wProcessorArchitecture; > WORD wReserved; > }; > }; > DWORD dwPageSize; > LPVOID lpMinimumApplicationAddress; > LPVOID lpMaximumApplicationAddress; > DWORD dwActiveProcessorMask; > DWORD dwNumberOfProcessors; > DWORD dwProcessorType; > DWORD dwAllocationGranularity; > WORD wProcessorLevel; > WORD wProcessorRevision; > } SYSTEM_INFO; > > Jordah Ferguson. > >