Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6085943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:41:45+00:00 2026-05-23T11:41:45+00:00

I am searching for a function to get time in milliseconds on a windows

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:41:46+00:00Added an answer on May 23, 2026 at 11:41 am

    You can’t load kernel32.dll, it’s already loaded into every process. And GetTickCount exists on every version of Windows, so you don’t need GetProcAddress to see if it exists. All you need is:

    #include <windows.h>
    #include <iostream>
    
    int main(void)
    {
        std::cout << GetTickCount() << std::endl;
    }
    

    A dynamic load example (since winmm.dll is not preloaded):

    #include <windows.h>
    #include <iostream>
    
    int main(void)
    {
        HMODULE winmmDLL = LoadLibraryA("winmm.dll");
    
        if (!winmmDLL) {
            std::cerr << "LoadLibrary failed." << std::endl;
            return 1;
        }
    
        typedef DWORD (WINAPI *timeGetTime_fn)(void);
        timeGetTime_fn pfnTimeGetTime = (timeGetTime_fn)GetProcAddress(winmmDLL, "timeGetTime");
    
        if (!pfnTimeGetTime) {
            std::cerr << "GetProcAddress failed." << std::endl;
            return 2;
        }
    
        std::cout << (*pfnTimeGetTime)() << std::endl;
        return 0;
    }
    

    I’ve successfully compiled and run this example using Visual Studio 2010 command prompt, no special compiler or linker options are needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a searching function, and have thought up of this query using
I was recently searching for a way to call the print function on a
Searching here I found that this question was already asked , but I think
I'm searching for this for quite some time now. I saw few similar questions
Well, I was searching for a simple collision detection function for as3, I found
Are there any PHP equivalents for these two functions? I tried searching but couldn't
I have this js code: $(#startSearch).live(click, function(event) { $(input:checkbox[name='searchId']:checked).each(function() { var searchId = $(this).val();
Searching for a string within a string is extremely well supported in .NET but
Searching on Google reveals x2 code snippets. The first result is to this code
It's hard to get the exact specific information on OOP you're searching for. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.