win7 vista 文件重定向切换

OSVERSIONINFOEX osif = {0};
osif.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
::GetVersionEx((OSVERSIONINFO*)&osif);
if (osif.dwMajorVersion == 6) //vista or 2008
{
HANDLE hProcess = GetCurrentProcess();
HANDLE hToken = 0;

if (OpenProcessToken(hProcess,TOKEN_ALL_ACCESS , &hToken))
{
DWORD dwEnabled = 0;
SetTokenInformation(hToken,TOKEN_INFORMATION_CLASS(24),&dwEnabled,sizeof(dwEnabled));//24==TokenVirtualizationEnabled
}
}
posted @ 2011-03-04 11:33  ahuo  阅读(274)  评论(0编辑  收藏  举报