Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey everyone

My first question is that, can c# lang communicate with motherboard component. Like RTC(Read Time Clock) Module, if yes Then tell me How can i getting the Date and Time from RTC Module so that if System time is change my application running with correct time.



If any one know about this pls help as soon as possible

Thanks
Vishal Jodh
Posted

1 solution

I'm not sure you can in modern OS's such as Win7 and above - they do tend to isolate you from the hardware as much as possible and forbid "Normal" privilege applications from touching it in any way.

But you don't need to anyway - just use the .NET components: DateTime.Now tells you the time right now - if the system time changes, so will the value it returns, because it reads the system time each time you call it.
 
Share this answer
 
Comments
vishal jodh 6-Dec-12 5:00am    
Thanks sir

But actually Now i am working on License key Generator project so My application calculate days, but in case some one changed system date and time then it will failed. so that's why, i am developing Calender(Date & Time) Windows Service App so that my application getting Date and Time from my own Service. if u know any idea regarding this issue pls tell.
OriginalGriff 6-Dec-12 5:35am    
Won't make any difference - your code cannot detect the change unless it is running at the time. Remember that when you power a PC up, you can enter the CMOS setup of the BIOS directly, and set the date and time there. Your code cannot be running at that time, so it cannot detect the change when it happens.

There are two things you can do:
1) Save the last date and time to disk, and check against it to see if it has moved back significantly (remember to allow for Summer / Winter clock changes, and also time corrections). Don't save too often though, as you will annoy people who have bought the product and do not want the HDD accessed all the time.
2) Read the actual UTC time from an internet time controller - this can help:
http://miromannino.it/network-time-protocol-request-in-c/
If you read that, they can't change it, so your trial limitation will work.
vishal jodh 6-Dec-12 6:22am    
Thanks Sir for all
OriginalGriff 6-Dec-12 6:38am    
You're welcome!

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