Click here to Skip to main content
15,616,780 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
hi everyone

i want to set date through my application (change system date from my app),

i found a code that use api ,i tried it,but it does not work in my pc,

maybe beacuse my os is win7,

can u explain me another way.

i searched it but i cant find good article.

i am sorry for my bad writing.
Updated 15-Apr-11 10:56am

It can be done through P/Invoke of the Windows API SetLocalTime.


Complete with C# code:[^].

Good luck,
Share this answer
Toli Cuturicu 15-Apr-11 17:22pm    
5, but... I wouldn't recommend it. I'd hate a software that does this.
Sergey Alexandrovich Kryukov 15-Apr-11 17:24pm    
Thank you and -- I agree, but we don't know the purpose, maybe it's a must.
You warning is valuable and should be taken into account, of course.
Sandeep Mewara 16-Apr-11 12:27pm    
Comment from OP:
thanks for your help,

but i told you ,it does not work in win 7.

do u have any solution?
Sergey Alexandrovich Kryukov 16-Apr-11 14:37pm    
I don't have Windows 7 installed right now, but... what exactly happens... chances are, you need to work with elevated privileges to run this code; this is one of the major Windows 7 difference; and there is nothing you can do about it (except XP compatibility mode).
Have a look at the SetSytemTime API as well[^].
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900