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 50 51 52 53
|
#include <windows.h>
#include <stdio.h>
#include <time.h>
//---------------------------------------------------------
int logtime(void)
{
FILE *f = fopen("logtime.txt", "a");
if(f)
{
time_t t = time(0);
fprintf(f, "%s", ctime(&t));
fclose(f);
return 1;
}
return 0;
}
//---------------------------------------------------------
int WINAPI WinMain(HINSTANCE a, HINSTANCE b, LPSTR c, int d)
{
MSG m;
CreateMutex(0, 0, "logtime");
if(GetLastError() == ERROR_ALREADY_EXISTS)
return 1;
// Ctrl + Alt + S pour logtime
RegisterHotKey(0, 1, MOD_CONTROL|MOD_ALT, 'S');
// Ctrl + Alt + Q pour quitter
RegisterHotKey(0, 2, MOD_CONTROL|MOD_ALT, 'Q');
while(GetMessage(&m, 0, 0, 0))
{
DispatchMessage(&m);
if(m.message == WM_HOTKEY)
{
if(m.wParam == 1)
logtime();
if(m.wParam == 2)
break;
}
}
UnregisterHotKey(0, 1);
UnregisterHotKey(0, 2);
return 0;
} |
Partager