The create function is supposed to return a handle to a timer. I am not sure how I'm supposed to do that.

I am planning on creating a class and in the implementation of the create function, I will set a variable to current time (using gettickcount () ) and set the expiry variable to what's passed in. In the isExpired function, I will compare the values against current time (again using gettickcount () ) and determine if timer is expired or not.

But I don't know how to create a handle for each timer the way the function definitions require me to. Any ideas?

Thank you

xpi0t0s

3May2011 15:30

Re: Creating a handle for an object? How?

Not enough info. What OS? Are the timers implemented by the OS or have ou implemented them?

A handle is just something the computer uses to be able to identify an object. It could be a pointer, or it could just be a number that indexes into a pointer or object table. For example:
1 "hello"
2 "world"
3 "foo"
4 "bar"

1-4 could be considered "handles" in this respect. The exact meaning of handle in your situation will depend on the situation, for example if these are Windows handles as implemented by the WinAPI, then the HANDLEs returned by CreateTimer() et al would count as valid handles that could be returned by your functions, unless for any reason you wanted to obfuscate the actual Windows HANDLE values themselves, in which case you'd want to create a lookup table so that your program could deduce the Windows HANDLE from the handle passed in, e.g.
1 Windows-HANDLE-1
2 Windows-HANDLE-2
3 Windows-HANDLE-3

then your program would get a Windows HANDLE and bung it in this table, return as a handle the lookup value, then on each entry to your library you would take the given handle (1-3) and lookup the actual Windows HANDLE which you would then use to call the Windows function.