将程序放到C:\program files\my programs\ 下,程序在相对有文件的生成和删除.在其他操作系统都可以运行.可移到vista上就不可以,而且用的也是管理员用户?

解决方案 »

  1.   

    用右键“run as administrator”运行就可以了。
    Vista下,即使管理员用户下,双击运行程序,一样只有普通权限,这是Vista UAC特性。
      

  2.   

    能不能现代码中实现 run as administrator
      

  3.   

    加manifast给你的程序,去网上搜一下,很多的
      

  4.   

    是manifest,一个XML格式的文件,程序的依赖项和规定权限可以在里边写明,特别是可以在里边规定你的程序启动时要求管理员权限。上网查查,很多资料的。
      

  5.   

    Vista 微软提供了一个应用程序兼容性工具,可以帮助确定、解决兼容问题http://www.microsoft.com/china/technet/prodtechnol/windowsvista/appcompat/prodguid.mspx
      

  6.   

    先给你个manifest文件格式参考:
    <?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="程序名" 
    type="win32" 
    /> 
    <description>程序描述</description> 
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> 
        <security> 
            <requestedPrivileges> 
                <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/> 
            </requestedPrivileges> 
        </security> 
    </trustInfo> 
    </assembly>如你程序名为hello.exe,那就把这些xml保存为hello.exe.manifest并放同一目录。
    requestedPrivileges这一节就是用来指定权限的。运行程序的时候,就会跳出UAC的确认对话框。不过,据说如果在xp sp2系统,requestedPrivileges这一节会造成系统有一定的机率蓝屏。你也可以在程序中进行一些检测,如果写文件失败,就提示要以管理员权限运行。