Important: Please read the Qt Code of Conduct -

Unable to write directly to the disk

  • I'm having a problem writing directly to a disk, I'm trying to write a Qt version of the old PARTCOPY (now obsolete on systems incompatible with 16-bit)

    I'm using Windows 10, and have my program elevated to Administrator privileges.

    Every time I try to open "\\.\A:" in with QIODevice::WriteOnly, I get an error message "The parameter is incorrect".

    Using Visual Studio step-wise debugging, I think I've found the problem occurs in QFSEnginePrivate::nativeOpen() when tring to execute CreateFile().

    The line:

    // WriteOnly can create files, ReadOnly cannot.
        DWORD creationDisp = (openMode & QIODevice::WriteOnly) ? OPEN_ALWAYS : OPEN_EXISTING;

    seems to be the cause. If I force the value of creationDisp to be OPEN_EXISTING, then I can get the file opened and I can write to the disk without any further problems. The issue is that I don't know what way I can get this working without using the debugger.

    Has anyone found a solution to this?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you opening the file in ReadWrite mode ?

Log in to reply