im working on my restarter for an ot, and i wonder how to get the time?
currently i just call CMD and get output of "echo %time%"
i supose that takes more cpu than *it cud have*
any1 know how to get the current time in c++?
Code:// Silent Restarter v1.1 by Yurez // edited by Hans Henrik. #include <windows.h> #include <iostream> int i = 0; int main(int argc, char *argv[]) { if (argc != 2) { std::cout << "your supose to drop an exe here!" << std::endl; return 1; } STARTUPINFO si; PROCESS_INFORMATION pi; GetStartupInfo(&si); SetErrorMode(SEM_NOGPFAULTERRORBOX); while (true) { CreateProcess(argv[1], NULL, NULL, NULL, false, HIGH_PRIORITY_CLASS, NULL, NULL, &si, &pi); if(i > 0) { std::cout << "restarted (or crashed) at: "; system("echo %time%"); // yeah.. know system aint the best way to go, ill better find out how to get system time c++-wise later :p std::cout << "(happend " << i << (i != 1? " times" : " time") << ")" << std::endl; } i += 1; WaitForSingleObject(pi.hProcess, INFINITE); } return 0; }