Unable to change the system zone setting on Windows Server 2008 R2.

Posted by Ganesh on Stack Overflow See other posts from Stack Overflow or by Ganesh
Published on 2010-06-09T04:55:08Z Indexed on 2010/06/09 5:02 UTC
Read the original article Hit count: 349

Filed under:

Hi All,

I have an MFC application that tries to change the system zone setting on the Windows Server 2008 R2. I am using the SetTimeZoneInformation() API which fails with the error code 1314 .i.e. “A required privilege is not held by the client.”. Please refer the sample code below:

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);
}

The MFC application has been developed using Visual Studio 2008 and is UAC aware i.e. the application has UAC enabled in its manifest file with the UAC execution level set to “HighestAvailable”. I have administrator privileges and when I run the application it still fails to change the system zone setting.

Thanks in Advance, Ganesh

© Stack Overflow or respective owner

Related posts about windows-server-2008