Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. UpTime of an application

UpTime of an application

Scheduled Pinned Locked Moved C / C++ / MFC
questionsysadmin
9 Posts 6 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John theKing
    wrote on last edited by
    #1

    What is the effective way to find the uptime of an application? I have a server application and i want to ask the server its uptime. For this purpose i need to record the time when application starts and then subtract the current time from initial time to get the difference. I want this difference in the format "dd:hh:min:sec", how can i do so ?

    S T D J 4 Replies Last reply
    0
    • J John theKing

      What is the effective way to find the uptime of an application? I have a server application and i want to ask the server its uptime. For this purpose i need to record the time when application starts and then subtract the current time from initial time to get the difference. I want this difference in the format "dd:hh:min:sec", how can i do so ?

      S Offline
      S Offline
      skaanji
      wrote on last edited by
      #2

      You can get current time using W32API function GetLocalTime(LPSYSTEMTIME);

      1 Reply Last reply
      0
      • J John theKing

        What is the effective way to find the uptime of an application? I have a server application and i want to ask the server its uptime. For this purpose i need to record the time when application starts and then subtract the current time from initial time to get the difference. I want this difference in the format "dd:hh:min:sec", how can i do so ?

        T Offline
        T Offline
        Tarundeep Singh Kalra
        wrote on last edited by
        #3

        just an idea ..not sure whether right or wrong...what about gettickcount()

        R J 2 Replies Last reply
        0
        • T Tarundeep Singh Kalra

          just an idea ..not sure whether right or wrong...what about gettickcount()

          R Offline
          R Offline
          Ryan Binns
          wrote on last edited by
          #4

          tarundeep singh wrote: what about gettickcount() :) It would work, but measuring uptime in milliseconds is probably overkill. Using GetSystemTime() will be more than adequate. Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
          Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

          1 Reply Last reply
          0
          • T Tarundeep Singh Kalra

            just an idea ..not sure whether right or wrong...what about gettickcount()

            J Offline
            J Offline
            John theKing
            wrote on last edited by
            #5

            tarundeep singh wrote: gettickcount() No, i can't use GetTickCount(), because its return value is of 4 bytes, and suppose my computer is up continuously for 2 months then these 4 bytes are not enough to get time difference.

            1 Reply Last reply
            0
            • J John theKing

              What is the effective way to find the uptime of an application? I have a server application and i want to ask the server its uptime. For this purpose i need to record the time when application starts and then subtract the current time from initial time to get the difference. I want this difference in the format "dd:hh:min:sec", how can i do so ?

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              John-theKing wrote: What is the effective way to find the uptime of an application? I have a server application and i want to ask the server its uptime. Are you wanting to know how long an application has been running, or how long the OS has been running?

              J 1 Reply Last reply
              0
              • J John theKing

                What is the effective way to find the uptime of an application? I have a server application and i want to ask the server its uptime. For this purpose i need to record the time when application starts and then subtract the current time from initial time to get the difference. I want this difference in the format "dd:hh:min:sec", how can i do so ?

                J Offline
                J Offline
                John M Drescher
                wrote on last edited by
                #7

                Use CTime and CTimeSpan John

                1 Reply Last reply
                0
                • D David Crow

                  John-theKing wrote: What is the effective way to find the uptime of an application? I have a server application and i want to ask the server its uptime. Are you wanting to know how long an application has been running, or how long the OS has been running?

                  J Offline
                  J Offline
                  John theKing
                  wrote on last edited by
                  #8

                  DavidCrow wrote: Are you wanting to know how long an application has been running, or how long the OS has been running? I want to know that how long my application is running ?

                  D 1 Reply Last reply
                  0
                  • J John theKing

                    DavidCrow wrote: Are you wanting to know how long an application has been running, or how long the OS has been running? I want to know that how long my application is running ?

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    See if GetProcessTimes() helps.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups