简体   繁体   English

Windows应用程序的管理员权限

[英]Administrator rights for Windows application

I need to create and write to a file under C:\\ on Windows. 我需要在Windows上的C:\\下创建并写入文件。 This obviusly require Administrator right. 这显然需要管理员权限。

My application consist on: 我的申请包括:

  • the CORE (.exe) 核心(.exe)
  • two .dll 两个.dll

Now, I saw a lot of time software (like games) that require Admin right during installation and after they can do whatever they want; 现在,我看到了很多时间的软件(例如游戏),它们需要在安装过程中以及在他们可以做任何想要的事情之后立即进行管理。 how is this possible? 这怎么可能?

How could I do that via C++ ? 我如何通过C ++做到这一点?

If you want your application to always run as administrator, you can specify this in your application's manifest file. 如果希望您的应用程序始终以管理员身份运行,则可以在应用程序的清单文件中进行指定。

Specifically, you will need to add something like this: 具体来说,您将需要添加以下内容:

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
  <security>
    <requestedPrivileges>
      <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
    </requestedPrivileges>
  </security>
</trustInfo>

More on application manifest files can be found in MSDN. 在MSDN中可以找到有关应用程序清单文件的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM