码迷,mamicode.com
首页 > 其他好文 > 详细

获取管理员权限

时间:2015-02-01 21:38:21      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

获取管理员权限:

void GainAdminPrivileges(UINT idd, BOOL bWait){  
    CString         strCmd;  
    CString         strApp;  
  
    strCmd.Format (_T("/adminoption %d"), idd);  
  
    CSVPToolBox svpTool;  
    strApp = svpTool.GetPlayerPath();  
  
  
    SHELLEXECUTEINFO execinfo;  
    memset(&execinfo, 0, sizeof(execinfo));  
    execinfo.lpFile         = strApp;  
    execinfo.cbSize         = sizeof(execinfo);  
    execinfo.lpVerb         = _T("runas");  
    execinfo.fMask          = SEE_MASK_NOCLOSEPROCESS;  
    execinfo.nShow          = SW_SHOWDEFAULT;  
    execinfo.lpParameters   = strCmd;  
  
    ShellExecuteEx(&execinfo);  
  
    if(bWait)  
        WaitForSingleObject(execinfo.hProcess, INFINITE);  
}  

 

获取管理员权限

标签:

原文地址:http://www.cnblogs.com/liaocheng/p/4266076.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!