Check AUM 10.
There's a code snippet there showing you how to do it.

Here you go:
http://aum.conitec.net/aum10/english/aum10/index.html