This code, which has hardly been tested, but has been used for exactly what you want, should help with that:
http://www.blitzbasic.com/codearcs/codearcs.php?code=1364
There are probably others too, but mine is obviously the first one that came to mind.
Edit: Ah, here's another: http://www.blitzbasic.com/codearcs/codearcs.php?code=732
http://www.blitzbasic.com/codearcs/codearcs.php?code=1364
There are probably others too, but mine is obviously the first one that came to mind.
Edit: Ah, here's another: http://www.blitzbasic.com/codearcs/codearcs.php?code=732