Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to set Windows file permissions in Qt/C++
    primarykey
    data
    text
    <p>In my Qt 4.7.4 x64 C++ app I'm building in Qt Creator 2.5.0, I want to give full access to everyone for a file. I'm using <code>QFile::setPermissions</code>, which I believe works fine for Mac and Linux, but it doesn't work for Windows. According to <a href="https://stackoverflow.com/questions/5021645/qt-setpermissions-not-setting-permisions">Qt setPermissions not setting permisions</a>, I should use </p> <pre><code>SetNamedSecurityInfoA("C:\file.txt", SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, NULL, NULL); </code></pre> <p>But I don't know what to #include to make it work. I tried:</p> <pre><code>#ifdef Q_WS_WIN #include "Windows.h" #endif </code></pre> <p>based on what I found <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa379283(v=vs.85).aspx" rel="nofollow noreferrer">here</a>. But when I compile, I get <code>C3861: 'SetNamedSecurityInfo': identifier not found</code> (among some other new errors).</p> <p>When I mouse over my <code>#include "Windows.h"</code>, I get the tooltip: <code>C:\Program Files\Microsoft SDKs\Windows\v7.0\include\Windows.h</code>, and I can press F2 and jump to that file. We have other files in our project that include that same Windows.h, and they compile fine.</p> <p>How do I set file permissions on Windows for everyone to read/write? If SetNamedSecurityInfo is what I want (I guess SetNamedSecurityInfoW in my case since my users may be running OS's in any language), what do I #include to be able to use it? Better yet, how do I figure out what to #include, so I know for next time I need to use the Windows API?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload