CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2005
    Posts
    3

    Smile Need information about the PC time

    Hello all,

    I need to know if it exists an incremental time available through a Windows API. I want to mean a data that is always incremented each time the PC is booted up. This data mustn't be possible to decrease even if the PC or BIOS time is changed to the past. Surely, I'll use this API to protect a software (something like FlexLm does). I hope that's clearly enough to be able to help me. Anyway, please let me know if more information required.

    Kind regards,

    Vlad

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Need information about the PC time

    I don't know anything like that. But you can use a registry key that you can decrement each time. Hoever this key should not be easy to spot or linked to your app. You can create a GUID for that.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Jan 2005
    Posts
    3

    Re: Need information about the PC time

    Quote Originally Posted by cilu
    I don't know anything like that. But you can use a registry key that you can decrement each time. Hoever this key should not be easy to spot or linked to your app. You can create a GUID for that.
    Yes, I thought about this buthow to decrement it? I decrement with respect of something. I'll give an exampl: you have just 3 days left until the license expires. When you start the application today you'll know that you have only three days of using before expiration. Then, you quit the software and two days later (you have only one day left) you change the PC (wondows or bios) time and you start again the application. If you use a registry key that you have to decrement I don't have a reference to decrease it with respect of.
    Do you have any idea about how to do that?

    Kind regards,

    Vlad

  4. #4
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    3,128

    Re: Need information about the PC time

    How about storing the number of seconds required for 3 days, i.e. 3 * 24 * 60 * 60, in the registry. When your program starts up, it start its counter from 0 sec. When it is terminated, your program has captured the elapsed that it is being run. Then you can update the total available time by substracting with the elapsed time. If the total available becomes zero, your program will not run.

  5. #5
    Join Date
    Jan 2005
    Posts
    3

    Re: Need information about the PC time

    Quote Originally Posted by Kheun
    How about storing the number of seconds required for 3 days, i.e. 3 * 24 * 60 * 60, in the registry. When your program starts up, it start its counter from 0 sec. When it is terminated, your program has captured the elapsed that it is being run. Then you can update the total available time by substracting with the elapsed time. If the total available becomes zero, your program will not run.
    Indeed, this permits to count the usage time of the application. But usually we have an expiration date that invalidates the application start-up even if the application was used or not.
    I need to compare the value stored (and updated) in registry with something else that can't be reversed (as the date). I heard about a counter of the CPU that is always incrementing. Do you know something about such a countero or any other idea?

    Regards,

    Vlad

  6. #6
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    3,128

    Re: Need information about the PC time

    I don't know if there is any such counter available. If not, you can probably write one yourself. Not sure if this is appropriate, you can write an NT Service that starts up automatically whenever the PC boots up. By periodically, substracting the time as well as monitoring the time and date, you should be unable to detect date change and thus avoid falling for the trick.

  7. #7
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    762

    Re: Need information about the PC time

    Instead of using the registry, you should encrypt the data and append it to your executable. That way it's much more difficult to foil the protection scheme because they have to break the encryption and hex edit the binary file where as the registry example is just finding a key and changing it or even deleting it.

  8. #8
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    1,342

    Re: Need information about the PC time

    Instead of using the registry, you should encrypt the data and append it to your executable. That way it's much more difficult to foil the protection scheme because they have to break the encryption and hex edit the binary file where as the registry example is just finding a key and changing it or even deleting it.
    Just out of curiosity, how do you append something to your exe file?
    Old Unix programmers never die, they just mv to /dev/null

  9. #9
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    762

    Re: Need information about the PC time

    Quote Originally Posted by HighCommander4
    Just out of curiosity, how do you append something to your exe file?
    I know it's possible and I've heard of others doing that, however; I do not know how myself

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured