Below is a link you may find interesting. It's in Polish though. Try Google Translate or if you don't really need to understand the article's text, just focus on the code itself.
http://delphi.dathox.com/2009/12/ser...cz2-i-cz3.html