ShellExecute(NULL, _T("Open"), _T("C:\\test\\a.pdf"), NULL, NULL, SW_SHOWMAXIMIZED);
在win7下,程序运行时会触发UAC控制,有没有方法降低程序所需的权限?

解决方案 »

  1.   

    ShellExecuteEx();
    SHELLEXECUTEINFO结构体的lpVerb = _T("run as");
      

  2.   

    方法一
    <?xml version="1.0" encoding="utf-8"?> 
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> 
    <security> 
    <requestedPrivileges> 
    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> 
    </requestedPrivileges> 
    </security> 
    </trustInfo> 
    </assembly>方法二
    ShellExecuteEx
     lpVerb = L"runas";
     lpFile = L"notepad.exe"方法三
    用Microsoft Application Compatibility Toolkit 将你的程序添加到UAC白名单
    把你a.pdf移动到非系统分区看看还会不会出发UAC控制
      

  3.   


    SHELLEXECUTEINFO ShellInfo; 
    memset(&ShellInfo, 0, sizeof(ShellInfo)); 
    ShellInfo.cbSize = sizeof(ShellInfo);
    ShellInfo.hwnd = NULL;
    ShellInfo.lpVerb = _T("run as");
    ShellInfo.lpFile = _T("c:\\test\\a.pdf");
    ShellInfo.nShow = SW_SHOWNORMAL;
    ShellInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
    ShellExecuteEx(&ShellInfo);
    一样,也还是需要提权
      

  4.   

    XML文件,将它改名为你程序名.manifest放到程序目录下,,用记事本之类的文本编辑器就可以编辑
      

  5.   

    没作用,还是会弹出uac的提示框
      

  6.   

    LZ的目的是降低使用权限,不弹出consent
    你们是南辕北辙
      

  7.   

    consent.exe的窗口中显示的是你的程序还是阅读pdf的程序?
    是运行ShellExecute(NULL, _T("Open"), _T("C:\\test\\a.pdf"), NULL, NULL, SW_SHOWMAXIMIZED);时才有uac还是双击你的程序就出来?
      

  8.   

    用2楼的第三种方法将pdf程序加入uac白名单…
      

  9.   


    程序启动时就有提示了,只有把ShellExecute注释掉,就没问题了
      

  10.   


    那个对话框中是你的程序名还是pdf阅读器的
      

  11.   

    当然是我程序的了。只要我加上ShellExecute,编译出来的程序图标上都会带有一个小盾牌,去掉,盾牌就没了
      

  12.   

    你看一下你的程序的manifest资源,把里面的
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">  
    <security>  
    <requestedPrivileges>  
    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />  
    </requestedPrivileges>  
    </security>  
    </trustInfo>  
    之类的去掉,或者选择不使用manifest
      

  13.   

    没有.mainfest文件,也没用这种资源
      

  14.   

    把exe发到[email protected]给我看看