public static bool CanUse() { TIMECAPS timeCaps = new TIMECAPS(); int result = WinMM.timeGetDevCaps(ref timeCaps, Marshal.SizeOf(timeCaps)); return(result != WinMM.TIMERR_NOERROR); }
public static uint timeGetDevCaps(ref TIMECAPS timeCaps, uint sizeTimeCaps) { timeCaps = new TIMECAPS() { wPeriodMin = 10, wPeriodMax = uint.MaxValue, }; return(MidiWinApi.MMSYSERR_NOERROR); }
static TimerAPI() { ourLock = new object(); var tc = new TIMECAPS(); timeGetDevCaps(ref tc, Marshal.SizeOf(tc)); ourMinPeriod = tc.periodMin; ourMaxPeriod = tc.periodMax; ourCurRequests = new List <int>(); }
/// <summary> /// Function to reset the timer. /// </summary> public void Reset() { TIMECAPS caps = default(TIMECAPS); if (_isHighResTimer) { if (Win32API.QueryPerformanceFrequency(out _frequency)) { Win32API.QueryPerformanceCounter(out _startTime); return; } _isHighResTimer = false; } if (_timePeriod > 0) { if (Win32API.timeEndPeriod(_timePeriod) == TimePeriodReturn.NoCanDo) { throw new Win32Exception(Resources.GOR_TIME_CANNOT_END); } } else { if (Win32API.timeGetDevCaps(ref caps, DirectAccess.SizeOf <TIMECAPS>()) != 0) { throw new Win32Exception(Resources.GOR_TIME_CANNOT_BEGIN); } _timePeriod = caps.MinPeriod; } if (Win32API.timeBeginPeriod(_timePeriod) == TimePeriodReturn.NoCanDo) { throw new Win32Exception(Resources.GOR_TIME_CANNOT_BEGIN); } UsingLowResTimers = true; _startTick = Environment.TickCount; _startTime = Win32API.timeGetTime(); }
private static extern int timeGetDevCaps(ref TIMECAPS ptc, int cbtc);
public static extern uint timeGetDevCaps(ref TIMECAPS timeCaps, uint sizeTimeCaps);
public static extern int timeGetDevCaps(ref TIMECAPS ptc, int cbtc);
public static extern MMRESULT timeGetDevCaps(out TIMECAPS ptc, uint cbtc = 8);