<p>How do you programmatically eject(safely remove) an USB mass storage device in Windows (XP)?</p>

You could spawn a process and use a
command line tool
. This would also work from other languages such as java where calling the Win32 api is harder.