Check out the GNAT sample here:

www.empirisoft.com/support/showthread.php?t=180