How To Get Windows Uptime

CK CK 3776 
Created at  
1,469 0 0
Find how long Windows has been working...

function UpTime: string;
const
ticksperday : integer = 1000 * 60 * 60 * 24;
ticksperhour : integer = 1000 * 60 * 60;
ticksperminute : integer = 1000 * 60;
tickspersecond : integer = 1000;

var
 t : longword;
 d, h, m, s : integer;

begin
 t := GetTickCount;

 d := t div ticksperday;
 dec(t, d * ticksperday);

 h := t div ticksperhour;
 dec(t, h * ticksperhour);

 m := t div ticksperminute;
 dec(t, m * ticksperminute);

 s := t div tickspersecond;

 Result := 'Uptime: '+IntToStr(d)+ ' Days '+IntToStr(h)+' Hours '+IntToStr(m)+' Minutes '+IntToStr(s)+' Seconds';
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  label1.Caption:=UpTime;
end;

This is useful function for making remote management application that have to check system status frequently.

I used this function to reboot at certain condition such as Uptime.
Tags PC 켜져 있는 시간 알아내는 방법 Remote Management TickCount Uptime 켜져있는시간 Facebook X
Comments 0
  1. How to Split and Merge Files
    617
  2. Get File 'Last Modified' attribute
    465
  3. From/to the 8.3 (short) format to/from the long format
    575
  4. Delete folders recursively
    417
  5. Delete files with the ability to UNDO
    436
  6. Does my CD-ROM drive contain an audio CD?
    361
  7. Convert a mapped drive to a full UNC path
    830
  8. Checking If File Is In Use
    917
  9. Browse for Computers, Folders, Files and Printers
    570
  10. How to draw Transparent Text on bitmap
    385
  11. How Do I Remove The Application Icon From The Taskbar?
    1,096
  12. How To Show The Print Dialog And Print Text Files
    1,292
  13. How To Make An Animated Application Icon
    813
  14. How To Pass The Focus To The Next/prior Control
    1,200
  15. How To Make Rounded Windows
    1,222
  16. How To Find Out Total And Available Memory
    1,627
  17. How To Change The System Time
    1,244
  18. How To Get The Windows OS Version
    614
  19. How To Change The Desktop Wallpaper
    2,129
  20. How To Get The Windows Language
    1,132
  21. How To Make A Gradient Filled Form
    834
  22. How can I hide the caption bar on a form?
    1,397
  23. How To Send An E-mail By Code
    1,108
  24. How To Open Url In Default Webbrowser
    456
  25. How To Check If A Soundcard Is Installed
    1,554
  26. How To Change Screen Resolution
    2,059
  27. How To Force The Correct Decimal Separator
    1,761
  28. How To Register Own File Types
    1,179
  29. How To Get Volume Name
    407
  30. How To Get Windows And System Directory
    2,671
Recently updated
  1. How do I create animated background for Google Meet?
    18,994
  2. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    192
  3. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    75
  4. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    151
  5. Array of arguments passed to script in PHP
    83
  6. Invalid Auction Storms in Ad Tech
    91
  7. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    194
  8. The Two Clocks of Ad Server Architecture
    61
  9. Frequency Cap Architecture Overview
    505
  10. Collecting Proof-of-Play from 100,000 Screens
    139
  11. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    276
  12. What is RedisVL?
    102
  13. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    218
  14. TPU & GPU Cluster Management Tools
    229
  15. The Concept of Scaffolding in AI Agents
    217
  16. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    568
  17. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    246
  18. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    321
  19. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    196
  20. Machine Learning: Training vs. Ranking
    200
  21. The Continuous Learning Machine: Designing a Loop That Actually Turns
    212
  22. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    188
  23. Designing a Data Curation System Around a Vector Database
    212
  24. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    228
  25. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    646
  26. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    179
  27. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    203
  28. Understanding Data Lineage
    251
  29. System Requirements and Architecture: Intelligent Priority-Based Scheduler
    159
  30. GPU & LLM Cluster Infrastructure & Task Scheduling Architecture
    229