2010年2月23日 星期二

[轉載]VC/ Vista / Run as administrator 權限

引用 http://www.codeproject.com/KB/vista-security/VistaElevator.aspx?df=100&forumid=368223&exp=0&select=1909847

擷取 Starting an elevated process段 使用ShellExecuteinfo 中的run as 讓系統判斷目前是否需要出現Run as administrator 提示dialog.

BOOLRunElevated( HWND hwnd,
LPCTSTR pszPath,
LPCTSTR pszParameters = NULL,
LPCTSTR pszDirectory = NULL )
{
SHELLEXECUTEINFO shex;
memset( &shex, 0, sizeof( shex) );
shex.cbSize = sizeof( SHELLEXECUTEINFO );
shex.fMask = 0;
shex.hwnd = hwnd;
shex.lpVerb = _T("runas");
shex.lpFile = pszPath;
shex.lpParameters = pszParameters;
shex.lpDirectory = pszDirectory;
shex.nShow = SW_NORMAL;

return ::ShellExecuteEx( &shex );
}

[Search keywords]
[Vista 權限 執行]
[安裝 install regsvr32 COM]
[registry 存取]
[Administrator system account privilege]

沒有留言: