码迷,mamicode.com
首页 > 其他好文 > 详细

Qt更改文件权限

时间:2015-01-25 13:46:36      阅读:271      评论:0      收藏:0      [点我收藏+]

标签:

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更改文件权限

标签:

原文地址:http://www.cnblogs.com/sz-leez/p/4248103.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!