I want to pick up on this from a comment:
I would rather use built-in functionality if possible
Why?
Seriously. Write it yourself. It will do exactly what you want with no confusion about whether it is borked or just "working as intended".
Oh, and it will be portable, and it won't get deprecated in 2 years time.
Topic:
App & System Services
SubTopic:
Core OS
Tags: