I am searching for a function to get time in milliseconds on a windows machine. Essentially, I want to call this WinAPI function GetTickCount(), but I’m stuck on “use LoadLibrary(…) n call GetTickCount() function” part..
I searched every forum n googled it but everywhere people have used incomplete codes that don’t compile..Can anyone write a short sample program to load kernel32.dll and call GetTickCount() to display the time in milliseconds?
Please write code that compiles!
You can’t load
kernel32.dll, it’s already loaded into every process. AndGetTickCountexists on every version of Windows, so you don’t needGetProcAddressto see if it exists. All you need is:A dynamic load example (since
winmm.dllis not preloaded):I’ve successfully compiled and run this example using Visual Studio 2010 command prompt, no special compiler or linker options are needed.