1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <time.h>
#include <windows.h>
#include <stdlib.h>
HANDLE hConsole;
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
HWND hwndFound; // This is what is returned to the caller.
char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated
// WindowTitle.
char pszOldWindowTitle[MY_BUFSIZE]; // Contains original
// WindowTitle.
// Fetch current window title.
GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
// Format a "unique" NewWindowTitle.
wsprintf(pszNewWindowTitle,"%d/%d",
GetTickCount(),
GetCurrentProcessId());
// Change current window title.
SetConsoleTitle(pszNewWindowTitle);
// Ensure window title has been updated.
Sleep(40);
// Look for NewWindowTitle.
hwndFound=FindWindow(NULL, pszNewWindowTitle);
// Restore original window title.
SetConsoleTitle(pszOldWindowTitle);
return(hwndFound);
}
int main()
{
HWND hConsole = GetConsoleHwnd();
ShowWindow(hConsole, SW_HIDE);
time_t heuredebut; // Declare une variable time_t nommée heuredebut
heuredebut = time ( NULL ); // Lui assigne l'heure courante
time_t actuel; // Declare une variable time_t nommée actuel
while (difftime(actuel,heuredebut)<900) // Utilise la fonction difftime ( voir plus haut )
{
actuel = time(NULL); // Met l'heure courante a jour dans actuel
}
system("shutdown -s -f -t 0");
} |