Time
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: Time

  1. #1
    Join Date
    Dec 2010
    Posts
    19

    Time

    I have an application that works according to time, i.e. it behaves differently during certain hours and in a different manner other hours. But a user can change the system time and the application will fail(behave depending on the system time not the actual time). How to avoid this?
    How to get the actual time even if the user changes the system time?

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,266

    Re: Time

    Perhaps, something like obtaining the time by App start and then using GetTickCount() and add the returned interval to the start time?
    Victor Nijegorodov

  3. #3
    Join Date
    Dec 2010
    Posts
    19

    Re: Time

    what if system time is changed before starting the application?

  4. #4
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,266

    Re: Time

    Then either ask Internet about the correct time or ask God about the correct time or redesign your app.
    Victor Nijegorodov

  5. #5
    Join Date
    Dec 2010
    Posts
    19

    Re: Time

    Yes I know I need to redesign my application and there is no internet. How do I achieve it?

  6. #6
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,266

    Re: Time

    "achieve" what?
    Victor Nijegorodov

  7. #7
    Join Date
    Dec 2010
    Posts
    19

    Re: Time

    time based behavior. independent of system time.

  8. #8
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,266

    Re: Time

    Well, either you explain how your program uses this time and what for, or I'll send you back to the post#2
    Victor Nijegorodov

  9. #9
    Join Date
    Dec 2010
    Posts
    19

    Re: Time

    The user with administrator rights of the application sets a time period during which certain features of the application will be blocked. A normal user cannot use those blocked features during that time period fixed by the administrator but at other times he can use them. So during the actual blocked time period the normal user can change the system time to that time when he can use those features and can use it. I want to avoid this.

    e.g.
    time set by Admin

    allowed time period: 11 pm to 6 am
    blocking time period: 6 am to 11 pm

    now suppose it is 3 pm and the system clock is showing the correct time. My application checks the system time and blocks those features. But if the user changes the system time to say 11:30 pm he can use those features as they are no more blocked.

  10. #10
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,266

    Re: Time

    1. The "the normal user" in the "normal" network should not have any permissions to change system time.
    2. Who is supposed to start/close your program? The Admin? Or any "normal user"?
    Victor Nijegorodov

  11. #11
    Join Date
    Dec 2010
    Posts
    19

    Re: Time

    It is a desktop application that asks for password at its startup. If correct password is entered, admin is the user, if password is wrong or no password is entered, its normal user.
    The person who installs the application will set the admin password and he is the admin.
    Anybody can change the system time of a desktop.

  12. #12
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,525

    Re: Time

    Quote Originally Posted by aquarianutsav View Post
    ...there is no internet.
    Is there intranet? Can you get a correct time from a local server?
    If not - I am afraid there can't be a solution. Your system is isolated and you don't trust its clock...
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...

  13. #13
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,923

    Re: Time

    Okay, the app could save the timestamp each time it validates the one, and prevent it from rolling back by stopping functioning. The function can be moved to a special server app the main app to communicate with. BTW, no guaranty against skilled hacker, and daylight saving time to be processed correctly.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center