C♯相談室 Part19
■ このスレッドは過去ログ倉庫に格納されています
0595394
NGNGprivate static int TimerID;
private static uint TimerDiff;
private struct TIMECAPS
{
public uint wPeriodMin;
public uint wPeriodMax;
}
private delegate bool TimeProcDelegate(int uID, int uMsg, int dwUser, int dw1, int dw2);
[DllImport("winmm.dll")] private static extern void timeBeginPeriod(uint x);
[DllImport("winmm.dll")] private static extern int timeGetDevCaps(ref TIMECAPS lpTimeCaps, int uSize);
[DllImport("winmm.dll")] private static extern int timeSetEvent(uint uDelay, uint uResolution, TimeProcDelegate lpFunction, int dwUser, int uFlags);
public static void Test()
{
TIMECAPS tc = new TIMECAPS();
timeGetDevCaps(ref tc, Marshal.SizeOf(tc));
TimerDiff = Math.Min(Math.Max(tc.wPeriodMin, 5), tc.wPeriodMax);
timeBeginPeriod(TimerDiff);
TimeProcDelegate tpd = new TimeProcDelegate(Timer);
TimerID = timeSetEvent(5, TimerDiff, tpd, 0, 0); // TIME_ONESHOT = 0 1回だけ呼ぶ
}
private static bool Timer(int uID, int uMsg, int dwUser, int dw1, int dw2)
{
TimeProcDelegate tpd = new TimeProcDelegate(Timer);
TimerID = timeSetEvent(5, TimerDiff, tpd, 0, 0); // TIME_ONESHOT = 0 1回だけ呼ぶ
return true;
}
■ このスレッドは過去ログ倉庫に格納されています