Is there any function in C to check if a computer goes to sleep , hibernate or locked and wakes up from this state?
In msdn, they provided for C# , C++ , but not for C My OS is windows7
Below is the code that I use to check the length of time between starting a program and stopping it (turning off the system terminates the program, so you can measure the length of time in this way).
#include <stdio.h> #include <stdlib.h> #include <conio.h> #include<time.h> clock_t start_time=0; void bye (void) { FILE *read,*write; write=fopen("F:\\count.txt","w"); clock_t end_time=clock(); fprintf(write,"Time: %d",(end_time-start_time)/CLOCKS_PER_SEC); fclose(write); } int main (void) { start_time=clock(); atexit (bye); //exit (EXIT_SUCCESS); getch(); }
Similarly, I want to check if / sleep / hibernate is blocked.
One possible way to wrap C ++ code (provided in a link) in c, as pointed out by @ddriver
But is this not possible in C at all?
source share