The user starts the application package installer. One of the components of the package requires admin rights and the installer must determine whether it is worth running this file during installation or not: if the user is admin - run, if not - skip the file.

What means of WinAPI can get such information about the current user?

    1 answer 1

    For example:

    #include "Shlobj.h" // ... BOOL IsAdmin = IsUserAnAdmin(); 

    Do not forget to shell Shell32.lib. Here is the documentation .

    • I understand that this function is outdated. - αλεχολυτ
    • @alexolut: Yes, but if it works, why is the code complicated when you can be simple? - VladD
    • If the vehicle is suitable, then please. But it should be borne in mind that in modern versions of the OS may not work properly. - αλεχολυτ
    • Oh, this Shell32.lib is not MinGW friendly. I will dance with a tambourine, then accomplish your goal or not. Thank you - Iceman
    • Failed to get IsUserAdmin () to work yet, I found an example like this - MinGW swears at the __leave command. What kind of beast is this? Looks like an assembler command. What to replace in the pros - break, continue ...? - Iceman