清单文件中的requestedExecutionLevel和失败的CopyFile()函数
只是尝试使用CopyFile()函数将文件从当前目录复制到C:\windows\system32\drivers 我还编写了包含“requestedExecutionLevel=“highestAvailable”的清单,并运行mt将其添加到生成的可执行文件中 当我尝试运行它时,Windows 7 UAC对话框弹出,我按“是”,但CopyFile()返回“拒绝访问”错误。 怎么了?我应该检查什么 我的清单文件:清单文件中的requestedExecutionLevel和失败的CopyFile()函数,c,winapi,uac,C,Winapi,Uac,只是尝试使用CopyFile()函数将文件从当前目录复制到C:\windows\system32\drivers 我还编写了包含“requestedExecutionLevel=“highestAvailable”的清单,并运行mt将其添加到生成的可执行文件中 当我尝试运行它时,Windows 7 UAC对话框弹出,我按“是”,但CopyFile()返回“拒绝访问”错误。 怎么了?我应该检查什么 我的清单文件: <?xml version="1.0" encoding="UTF-8" st
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<v3:trustInfo xmlns:v3="urn:schemas-microsoft-com:asm.v3">
<v3:security>
<v3:requestedPrivileges>
<v3:requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</v3:requestedPrivileges>
</v3:security>
</v3:trustInfo>
</assembly>
嗯,不太清楚“highestAvailable”是什么意思。消除所有疑问,改用“requireAdministrator”,它总是能够获得完全的管理员权限。还要确保使用正确的资源名称和ID、RT_清单和1。- requireAdministrator=始终需要管理员提升
- highestAvailable=如果是管理组的成员,则提升。如果是普通用户,则作为普通用户运行,不带高程
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
if (CopyFile ("aaa.sys", "C:\\windows\\system32\\drivers", FALSE)==FALSE)
ErrorExit ("CopyFile");