Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- }
Advertisement
Add Comment
Please, Sign In to add comment