【转】mfc win7获得管理员权限 使用WIN7风格 使用当前系统风格

原帖:http://blog.csdn.net/zengweicdut/article/details/8837688

在win7下,操作系统文件夹下的东西,需要程序拥有管理员权限才可以,程序拥有管理员权限的方法为:

一、添加管理员权限

1、在Resource View中添加一个文件夹,名称为24,将文件夹下的资源名称改为1.操作如图:

(1)

(2)

(3)

2、在资源1中添加下面的值,将下面的文字复制,粘贴进去就可以:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>  
< assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">  
< assemblyIdentity  
  version="1.0.0.0"  
  processorArchitecture="X86"  
  name="mulitray.exe.manifest"  
  type="win32"  
/>  
< trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">  
  <security>  
    <requestedPrivileges>  
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>  
    </requestedPrivileges>  
  </security>  
< /trustInfo>  
< /assembly> 

粘贴后如图:

然后,编译,软件就是拥有管理员权限的程序了。程序图标上,也会多一个盾,在XP下没有差异。

二、让应用程序使用当前系统的风格:

1、也是在ResourceView中添加一个24,1的资源,和添加管理员一样。

2、将1中的值设定为:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
< assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
< assemblyIdentity
    version="1.0.0.0"
    processorArchitecture="X86"
    name="Microsoft.Windows.DundasDemo"
    type="win32"
/>
< description>Your app description here</description>
< dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="X86"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
< /dependency>
< /assembly>

这样,程序就拥有了当前系统风格,比如win7的风格,下图就是加了当前风格的一个例子,按钮已经是win7风格了。

 

注意:程序只能拥有一个24,1的资源,而且资源下名字必须为24和1,也就导致,程序拥有管理员权限,就不能拥有系统风格,2者只能选1来使用,这一点是比较郁闷的。

 

posted @ 2015-06-30 22:13  Lthis  阅读(606)  评论(0编辑  收藏  举报