Juli
Juli

Reputation: 11

SetSystemTimeAdjustment Function - Windows

I am working on an application that uses the SetSystemTimeAdjustment function. However, I am getting a permissions error when that function is called - error code 1314.

I have updated my "User Rights" in Windows for operating as OS and setting system time to include administrators, users, but I still get the error.

Here's a sample of the code (not actual, but similar to): http://winterdom.com/dev/security/tokens

Upvotes: 1

Views: 1104

Answers (1)

Oleg
Oleg

Reputation: 221997

The error code 1314 shows clear, that you don't enable the privilege SE_SYSTEMTIME_NAME required for successful working of the function SetSystemTimeAdjustment. An example how to enable privilege you can find for example here.

One more advice. If you start as administrator Process Explorer you can verify which privileges has every process (you need SeSystemtimePrivilege), and which from the privileges are currently enabled or disabled.

To be sure that you will never have UAC problem, you should include in your program as a resource the UAC Manifest having

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

or

<requestedExecutionLevel  level="highestAvailable" uiAccess="false" />

Depend on the version of the Visual Studio which you use it could be just of the project setting ("Linker" / "Manifest file", "UAC Execution Level")

Upvotes: 4

Related Questions