tags:

views:

278

answers:

3

In VS9, when i call the GetTickCount() function, it automatically converts it into the GetTickCount64() function upon compilation. This second function only works on Vista+, and thus my program errors when run on XP.

How can I 'over-ride' this so that it calls the original GetTickCount() ?

Thanks

+2  A: 

Set WINVER to the version of windows you want to target. Or maybe it's _WIN32_WINNT or _WIN32_WINDOWS. Maybe even all of them...

Take a look at http://blogs.msdn.com/oldnewthing/archive/2007/04/11/2079137.aspx for details on that small mess-o-version macros.

However, I don't see that redefinition at all in the Windows SDK - could there be something else in our setup that's doing the redefinition (or maybe I'm missing it...)?

Michael Burr
I set the following:#define WINVER 0x0501#define _WIN32_WINNT 0x0501#define _WIN32_WINDOWS 0x0501and it still gets re-defined.However, when i create a simple new project that prints out GetTickCount(), it works fine on XP even without me having to define the above.
Try using the /showIncludes switch on the compiler (in the IDE it's in the C++/Advanced set of properties) - run a grep or something on all the files included to see where GetTickCount() is being redefined.
Michael Burr
A: 

Remember that you're not compiling your application for Vista or Windows XP, rather you're compiling for a 32-bit or 64-bit operating system. If your application needs to support other versions of Windows than 64-bit Vista, then specify in your build options to be 32-bit.

Jim H.
It is being compiled as 32-bit, the name of the function is just GetTickCount64() for some reason.
GetTickCount64 since it returns a 64-bit value. Normal GetTickCount is 32-bit and wraps in 48 or 49 days.
Michael
A: 

I set the following inside targetver.h:

#define WINVER 0x0501 
#define _WIN32_WINNT 0x0501
#define _WIN32_WINDOWS 0x0501

and it still gets re-defined. However, when i create a simple new project that prints out GetTickCount(), it works fine on XP even without me having to define the above. I did not change anything in the project settings. The only difference between the sample GetTickCount() that works and the one that doesn't is that it has plenty of other code around it and using it, but none of that code should be changing anything.

What could be causing this?

EDIT: One of the other files I was using was calling GetTickCount64() directly, and I did not know about this, so I assumed it was my own GetTickCount() function. Please ignore what i wrote above