Tuesday, June 3, 2014

Hiding/Unhiding files on windows using Qt

QString file;                      //Stores the path of file/folder
LPCWSTR path = file.toStdWString().c_str();
BOOL result = SetFileAttributes(path, FILE_ATTRIBUTE_HIDDEN);

if ((attr & FILE_ATTRIBUTE_HIDDEN) == FILE_ATTRIBUTE_HIDDEN) {
     SetFileAttributes(path, attr & ~FILE_ATTRIBUTE_HIDDEN);
}
 
This hides the files if its not hidden
else if its hidden it becomes visible..
 
That's all,
&
Thanks for reading if you like the content please like or comment.. 

Sunday, September 22, 2013

QString to LPCWSTR

QString file; //Could be any string
LPCWSTR path = file.toStdWString().c_str();

That's all,
&
Thanks for reading if you like the content please like or comment..