I'm not familiar with Windows device driver coding but since Windows does not abide the notion of device-as-file like UNIXes it may be that QFile cannot open the "file" returned. What does devPathName actually contain? Does that exist as a file?

Mixing the Windows API GetLastError() with the Qt QFile class does not strike me that it will be particularly reliable. Who knows what the last Windows API call that QFile made was. What does QFile::error() return.