Move some of the Windows specific code to a library.