I am pretty sure Windows has API for that. Check in MSDN.

Cheers,
_