[fpc-devel] Re: NotifyIconData not flexible enougth
Giulio Bernardi
ugilio at hotmail.com
Sat Nov 10 15:01:36 CET 2007
Declare the structure again (in lazarus IIRC there are already some windows types/records redefined) without ifdefs and make it compatible with the latest version. With some care you can use the same structure on all windows versions.
In fact usually windows structures are the same "at the beginning" across versions for compatibility reasons. You only need to fill the structure with data you need, set cbSize according to the version supported on the system your software is running on and call the api. Note that fields added in later versions are ignored by windows api that read the structure/their values are meaningless if you asked a windows api to write to the structure.
In your case, you could do something like this:
LoadLibrary('shell32');
GetProcAddress(handle,'DllGetVersion');
DllGetVersion(pversioninforecord);
if pversioninforecord.dwMajorVersion<=4 then icondata.cbsize:=NOTIFYICONDATAA_V1_SIZE
else icondata.cbsize:=NOTIFYICONDATAA_V2_SIZE;
Note that DllGetVersion doesn't exist in win95 without IE4, so if getprocaddress fails you know it's v1.
Moreover, if it's v1, szTip will be truncated to 64 characters.
I'd like to see ifdefs removed from fpc translations of win32 structures, but as Marco van de Voort said, the problem here is
that older code that simply does
icondata.cbsize:=sizeof(icondata)
won't work anymore on systems with libraries older than current versions.
bye,
Giulio
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx
More information about the fpc-devel
mailing list