【发布时间】:2010-06-09 04:55:08
【问题描述】:
我有一个 MFC 应用程序,它试图更改 Windows Server 2008 R2 上的系统区域设置。我正在使用失败的 SetTimeZoneInformation() API,错误代码为 1314。即“客户不拥有所需的特权。”。请参考下面的示例代码:
TIME_ZONE_INFORMATION l_TimeZoneInfo;
DWORD l_dwRetVal = 0;
ZeroMemory(&l_TimeZoneInfo, sizeof(TIME_ZONE_INFORMATION));
l_TimeZoneInfo.Bias = -330;
l_TimeZoneInfo.StandardBias = 0;
l_TimeZoneInfo.StandardDate.wDay = 0;
l_TimeZoneInfo.StandardDate.wDayOfWeek = 0;
l_TimeZoneInfo.StandardDate.wHour = 0;
l_TimeZoneInfo.StandardDate.wMilliseconds = 0;
l_TimeZoneInfo.StandardDate.wMinute = 0;
l_TimeZoneInfo.StandardDate.wMonth = 0;
l_TimeZoneInfo.StandardDate.wSecond = 0;
l_TimeZoneInfo.StandardDate.wYear = 0;
CString l_csDaylightName = _T("India Daylight Time");
CString l_csStdName = _T("India Standard Time");
wcscpy(l_TimeZoneInfo.DaylightName,l_csDaylightName.GetBuffer(l_csDaylightName.GetLength()));
wcscpy(l_TimeZoneInfo.StandardName,l_csStdName.GetBuffer(l_csStdName.GetLength()));
::SetLastError(0);
if(0 == ::SetTimeZoneInformation(&l_TimeZoneInfo))
{
l_dwRetVal = ::GetLastError();
CString l_csErr = _T("");
l_csErr.Format(_T("%d"),l_dwRetVal);
}
MFC 应用程序是使用 Visual Studio 2008 开发的,并且支持 UAC,即应用程序在其清单文件中启用了 UAC,并且 UAC 执行级别设置为“HighestAvailable”。我有管理员权限,当我运行应用程序时,它仍然无法更改系统区域设置。
提前致谢, 象头神
【问题讨论】: