One possibility using timeGetTime:
Code:
/*use of timeGetTime - link with winmm.lib (MinGW -lwinmm)*/
#include <windows.h>
#include <tchar.h>
int WINAPI _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,int nCmdShow)
{
DWORD start,finish,elapsed;
STARTUPINFO si;
PROCESS_INFORMATION pi;
TCHAR time_taken[128],title[]=_T("Use of timeGetTime");
ZeroMemory(&si,sizeof(si));
si.cb=sizeof(si);
ZeroMemory(&pi,sizeof(pi));
start=timeGetTime(); /*start timer*/
/*Start other program, for example, the windows calculator.*/
if(!CreateProcess(0,_T("calc.exe"),0,0,0,0,0,0,&si,&pi))
{
MessageBox(0,"error",title,MB_OK);
return 0;
}
/*Wait for child process to quit */
WaitForSingleObject(pi.hProcess,INFINITE);
/*and clean up its garbage*/
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
/*stop timer, calculate and display elapsed time*/
finish=timeGetTime();
elapsed=finish-start;
wsprintf(time_taken,_T("Elapsed time: %u milliseconds"),elapsed);
MessageBox(0,time_taken,title,MB_OK);
return 0;
}
Search the boards as there should be plenty of other examples.