-
Changing system time in VC++ program
I'd like to change my local computer's (NT) time in my C++ program using system("net
time \\[computer name] /set /y");
But it doesn't work, seems that I dun have such privilege to change the system
time. But I don't know how to use the function
BOOL AdjustTokenPrivileges(HANDLE TokenHandle, BOOL Privileges,
PTOKEN_PRIVILEGES NewState, DWORD BufferLength,
PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength);
I just dun know what i should pass in TokenHandle? How to I get the access
token?
or anyone know a way to change the system time in C++ program? pls tell me
if you know, thank you very much~
-
Re: Changing system time in VC++ program
If you are using the windows SDK, there is a handy function called SetSystemTime.
Look up the docs at MSDN online or in your SDK help. It takes one argument,
a SYSTEMTIME Structure.
"Gary" <garymok33@hotmail.com> wrote:
>
>I'd like to change my local computer's (NT) time in my C++ program using
system("net
>time \\[computer name] /set /y");
>But it doesn't work, seems that I dun have such privilege to change the
system
>time. But I don't know how to use the function
>
>BOOL AdjustTokenPrivileges(HANDLE TokenHandle, BOOL Privileges,
> PTOKEN_PRIVILEGES NewState, DWORD BufferLength,
> PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength);
>
>I just dun know what i should pass in TokenHandle? How to I get the access
>token?
>
>or anyone know a way to change the system time in C++ program? pls tell
me
>if you know, thank you very much~
>
-
Re: Changing system time in VC++ program
"Gary" <garymok33@hotmail.com> wrote:
>
>I'd like to change my local computer's (NT) time in my C++ program using
system("net
>time \\[computer name] /set /y");
>But it doesn't work, seems that I dun have such privilege to change the
system
>time. But I don't know how to use the function
>
>BOOL AdjustTokenPrivileges(HANDLE TokenHandle, BOOL Privileges,
> PTOKEN_PRIVILEGES NewState, DWORD BufferLength,
> PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength);
>
>I just dun know what i should pass in TokenHandle? How to I get the access
>token?
>
>or anyone know a way to change the system time in C++ program? pls tell
me
>if you know, thank you very much~
>
"Net Time" is used for setting the computer's local time to match the time
on another server on the network. The complaint you are receiving is because
you do not have access to the other computer. If the computer is yourself
then it is because you are not an administrator or power user.
Assuming you want to match time with another computer, then you must be mapped
to the server. You can use "NET USE" to do this.
Assuming you just want to set the time, use the suggestion of the other respondent.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|