Added functions to influence the system timer precision.

This commit is contained in:
LoRd_MuldeR 2014-12-06 22:07:08 +01:00
parent e3de94a9b1
commit 3ac2f782e3
2 changed files with 19 additions and 0 deletions

View File

@ -152,6 +152,10 @@ namespace MUtils
//Process ID //Process ID
MUTILS_API quint32 process_id(const QProcess *proc); MUTILS_API quint32 process_id(const QProcess *proc);
//System timer resolution
MUTILS_API bool setup_timer_resolution(const quint32 &interval = 1);
MUTILS_API bool reset_timer_resolution(const quint32 &interval = 1);
//Check if debugger is present //Check if debugger is present
MUTILS_API void check_debugger(void); MUTILS_API void check_debugger(void);

View File

@ -29,6 +29,7 @@
#include <Sensapi.h> #include <Sensapi.h>
#include <Shellapi.h> #include <Shellapi.h>
#include <PowrProf.h> #include <PowrProf.h>
#include <Mmsystem.h>
//Internal //Internal
#include <MUtils/Global.h> #include <MUtils/Global.h>
@ -933,6 +934,20 @@ quint32 MUtils::OS::process_id(const QProcess *proc)
return (procInf) ? procInf->dwProcessId : NULL; return (procInf) ? procInf->dwProcessId : NULL;
} }
///////////////////////////////////////////////////////////////////////////////
// SYSTEM TIMER
///////////////////////////////////////////////////////////////////////////////
bool MUtils::OS::setup_timer_resolution(const quint32 &interval)
{
return timeBeginPeriod(interval) == TIMERR_NOERROR;
}
bool MUtils::OS::reset_timer_resolution(const quint32 &interval)
{
return timeEndPeriod(interval) == TIMERR_NOERROR;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// DEBUGGER CHECK // DEBUGGER CHECK
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////