3bc5b2c0a125e01a16f947ab9d1087a8adc654d6
[reactos.git] / reactos / apps / tests / alive / alive.c
1 /* $Id: alive.c,v 1.1 2001/03/18 20:20:13 ea Exp $
2 *
3 */
4 #include <windows.h>
5 #include <stdlib.h>
6
7 HANDLE StandardOutput = INVALID_HANDLE_VALUE;
8 WCHAR Message [80];
9 DWORD CharactersToWrite = 0;
10 DWORD WrittenCharacters = 0;
11 INT d = 0, h = 0, m = 0, s = 0;
12
13 int
14 main (int argc, char * argv [])
15 {
16 StandardOutput = GetStdHandle (STD_OUTPUT_HANDLE);
17 if (INVALID_HANDLE_VALUE == StandardOutput)
18 {
19 return (EXIT_FAILURE);
20 }
21 while (TRUE)
22 {
23 /* Prepare the message and update it */
24 CharactersToWrite =
25 wsprintfW (
26 Message,
27 L"Alive for %dd %dh %d' %d\" \r",
28 d, h, m, s
29 );
30 WriteConsoleW (
31 StandardOutput,
32 Message,
33 CharactersToWrite,
34 & WrittenCharacters,
35 NULL
36 );
37 /* suspend the execution for 1s */
38 Sleep (1000);
39 /* increment seconds */
40 ++ s;
41 if (60 == s) { s = 0; ++ m; }
42 if (60 == m) { m = 0; ++ h; }
43 if (24 == h) { h = 0; ++ d; }
44 }
45 return (EXIT_SUCCESS);
46 }
47
48 /* EOF */