Is it possible to change the tick count value returned from GetTickCount()?

0

Issue

I’m trying to do some testing and it requires the Windows system to be up and running for 15 Real-Time minutes before a certain action can ever occur. However, this is very time consuming to HAVE to wait the 15 real-time minutes.

Is there a way to change the value GetTickCount() returns so as to make it appear that the system has been running for 15 real-time minutes?

Edit: There is an app that does something close to what I want, but it doesn’t quite seem to work and I have to deal with hexadecimal values instead of straight decimal values: http://ysgyfarnog.co.uk/utilities/AdjustTickCount/

Solution

Not directly.

Why not just mock the call, or replace the chunk of code that does the time check with a strategy object?

struct Waiter
{
    virtual void Wait() = 0;
    virtual ~Waiter() {};
};

struct 15MinWaiter : public Waiter
{
    virtual void Wait()
    {
        //Do something that waits for 15 mins
    }
};

struct NothingWaiter : public Waiter
{
    virtual void Wait()
    {
        //Nill
    } 
};

You could do similar to mock out a call to GetTickCount, but doing this at the higher level of abstraction of whatever is doing the wait is probably better.

Answered By – Billy ONeal

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More