Some programs are automatically asking for administrator rights when you run them. These programs are marked with a little shield in the bottom right corner:
Now I'm wondering how I could accomplish this in C++.
Is there a function for this or do I need some special compiler/linker commands for that?
You must be probably looking for CreateProcessAsUser or CreateProcessWithLogonW function.
There is one more option like this:-
Soemthing like this:
And as Syam correctly mentioned in the comments the solution could be to embed a manifest in the executable.