首页 > 代码库 > Qt更改文件权限
Qt更改文件权限
Qt更改文件权限
static void ChangeFilePermission( const QString &filePath )
{
#ifdef WIN32
QString cmd("icacls.exe \"") ;
cmd += filePath;
cmd += "\" /grant Everyone:(F)";
STARTUPINFOW si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
#ifndef _DEBUG
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
#endif
ZeroMemory(&pi, sizeof(pi));
CreateProcessW (NULL, // No module name (use command line).
(wchar_t*)cmd.utf16(), // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent‘s environment block.
NULL, // Use parent‘s starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi); // Pointer to PROCESS_INFORMATION structure.
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
#endif
}
Qt更改文件权限