mirror of
https://github.com/reactos/reactos.git
synced 2024-12-30 19:14:31 +00:00
dbf0e6e889
svn path=/trunk/; revision=11360
48 lines
928 B
C
48 lines
928 B
C
/* $Id: alive.c,v 1.1 2004/10/21 04:48:44 sedwards Exp $
|
|
*
|
|
*/
|
|
#include <windows.h>
|
|
#include <stdlib.h>
|
|
|
|
HANDLE StandardOutput = INVALID_HANDLE_VALUE;
|
|
CHAR Message [80];
|
|
DWORD CharactersToWrite = 0;
|
|
DWORD WrittenCharacters = 0;
|
|
INT d = 0, h = 0, m = 0, s = 0;
|
|
|
|
int
|
|
main (int argc, char * argv [])
|
|
{
|
|
StandardOutput = GetStdHandle (STD_OUTPUT_HANDLE);
|
|
if (INVALID_HANDLE_VALUE == StandardOutput)
|
|
{
|
|
return (EXIT_FAILURE);
|
|
}
|
|
while (TRUE)
|
|
{
|
|
/* Prepare the message and update it */
|
|
CharactersToWrite =
|
|
wsprintf (
|
|
Message,
|
|
"Alive for %dd %dh %d' %d\" \r",
|
|
d, h, m, s
|
|
);
|
|
WriteConsole (
|
|
StandardOutput,
|
|
Message,
|
|
CharactersToWrite,
|
|
& WrittenCharacters,
|
|
NULL
|
|
);
|
|
/* suspend the execution for 1s */
|
|
Sleep (1000);
|
|
/* increment seconds */
|
|
++ s;
|
|
if (60 == s) { s = 0; ++ m; }
|
|
if (60 == m) { m = 0; ++ h; }
|
|
if (24 == h) { h = 0; ++ d; }
|
|
}
|
|
return (EXIT_SUCCESS);
|
|
}
|
|
|
|
/* EOF */
|