|
Timer.rar
(659 Bytes, 下载次数: 1)
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.ComponentModel;
- using System.Runtime.InteropServices;
- namespace ClassLibrary1 // 名字空间
- {
- public class Timer
- {
- // SetTimer
- [DllImport("user32.dll", EntryPoint = "SetTimer")]
- private static extern int SetTimer(int hwnd, int nIDEvent, int uElapse, int lpTimerFunc);
- public int 设置时钟(int 窗口句柄, int 事件标识符, int 时钟周期, int 子程序指针)
- {
- int d = SetTimer(窗口句柄, 事件标识符, 时钟周期, 子程序指针);
- return d;
- }
- // 设置时钟...计时器...不所与高精度
- [DllImport("user32.dll", EntryPoint = "KillTimer")]
- private static extern int KillTimer(int hwnd, int nIDEvent);
- public bool 销毁时钟(int 窗口句柄, int 事件表示符)
- {
- int d = KillTimer(窗口句柄,事件表示符);
- if (d > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- // 销毁时钟
- [DllImport("user32.dll", EntryPoint = "GetMessageTime")]
- private static extern int GetMessageTime();
- public int 取函数执行时间()
- {
- return GetMessageTime();
- }
- }
- }
复制代码 |
|