hyprunz icon

Switch hide flag on Windows with Qt

hyprunz | PRO | 05/13/15 12:10:37 PM UTC | 0 ⭐ | 10315 👁️ | Never ⏰ | []
C++ (with Qt extensions) |

0 B

|

None

|

0 👍

/

0 👎

bool switchHideFlagOnWindows(const QString file)
{
#ifdef Q_OS_WIN32
    LPCWSTR path = (const wchar_t *)file.utf16();
    DWORD attr = GetFileAttributesW(path);
 
    if(attr == INVALID_FILE_ATTRIBUTES) {
        qDebug() << "Windowssystem error: INVALID_FILE_ATTRIBUTES";
        return false;
    }
 
    DWORD nattr = attr ^ FILE_ATTRIBUTE_HIDDEN;
 
    bool ret = SetFileAttributesW(path, nattr);
 
    if(!ret) {
        qDebug() << "Windowssystem couldn´t switch flag for hide!";
    }
 
    return ret;
#else
    //On non windows os this function will return always true - so that this function don´t block the process
    Q_UNUSED(file);
    return true;
#endif
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎