Use Windows Implementation Library to clean things up and get some RAII on handle types: https://github.com/microsoft/wil