Determining windows version during compile...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I'm doing some custom RAS work and I need to marshal the struct definition
below. The marshaling is no problem, however how can I acheive the effect of
the windows version pre-processor check in C#?

typedef struct tagRASDIALEXTENSIONS {
DWORD dwSize;
DWORD dwfOptions;
HWND hwndParent;
ULONG_PTR reserved;
#if (WINVER >= 0x500)
ULONG_PTR reserved1;
RASEAPINFO RasEapInfo;
#endif
} RASDIALEXTENSIONS;
 
Richard,

I wouldn't bother doing the check. Rather, I would declare the
structure whole, and then set the dwSize field appropriately depending on
what operating system you are running on when the call is made. It will
cost a little, since you might marshal over extra data that will not be
populated, but it shouldn't affect anything else (assuming that a pointer to
this structure is passed, the call stack shouldn't be affected, and the
other parameters won't be shifted in memory into a place where the function
doesn't expect them).

Hope this helps.
 
Back
Top