Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication2.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <stdio.h>
- #include <stdlib.h>
- #include <Windows.h>
- int _tmain(int argc, LPTSTR argv[])
- {
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
- FILETIME TIME_CREATION;
- FILETIME EXIT_TIME;
- FILETIME KERNEL_TIME;
- FILETIME USER_TIME;
- FILETIME TOTAL_TIME;
- ZeroMemory(&si, sizeof(si));
- ZeroMemory(&pi, sizeof(pi));
- CreateProcess(argv[1], argv[2], NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
- int a = GetLastError();
- //printf("%d", a);
- if (!a)
- {
- WaitForSingleObject(pi.hProcess, INFINITE);
- if (GetProcessTimes(pi.hProcess, &TIME_CREATION, &EXIT_TIME, &KERNEL_TIME, &USER_TIME))
- {
- int total_run_time = (*((ULONGLONG*)&EXIT_TIME) - *((ULONGLONG*)&TIME_CREATION)) / 10000;
- printf("Run time %dms", total_run_time);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement