cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Check file properties for admin requirem
Check file properties for admin requirement
May 31, 2017 at 1:50am UTC
Bingocat4
(105)
I am making a program that will open other programs, but some of them require administrator rights to open. I would like my program to be able to check if a file requires admin rights, and if it does then not open it. Is there a way to do this?
May 31, 2017 at 5:35am UTC
mbozzi
(3932)
You can obtain the permissions with
std::filesystem::file_status::permissions()
if C++17 library support is available. This is unlikely, so consider using the Boost.Filesystem equivalent
http://en.cppreference.com/w/cpp/filesystem/file_status/permissions
http://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/reference.html#file_status-observers
Less preferably, use POSIX stat(2)
http://pubs.opengroup.org/onlinepubs/009695399/functions/stat.html
Or even less preferably,
GetFileSecurity() if you're on Windows.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa446639(v=vs.85).aspx
Last edited on
May 31, 2017 at 8:18pm UTC
Topic archived. No new replies allowed.