const int WAIT_OBJECT_0 = 0;
        const int QS_ALLINPUT = 255;
        const int INFINITE = -1;        //自定义数据类型
        struct LARGE_INTEGER
        {
            public long QuadPart;        }
[DllImport("kernel32.dll")]
        static extern bool SetWaitableTimer(int hTimer, 
                                            LARGE_INTEGER pDueTime,
                                            int lPeriod,
                                            int pfnCompletionRoutine,
                                            int lpArgToCompletionRoutine,
                                            bool fResume);
        [DllImport("kernel32.dll")]
        static extern int CreateWaitableTimerA(int lpTimerAttributes,
                                              bool bManualReset,
                                              int  lpTimerName);
        [DllImport("kernel32.dll", SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool CloseHandle(int hObject);        [DllImport("user32.dll")]
        static extern int MsgWaitForMultipleObjects(int nCount, int pHandles,
           bool bWaitAll, int dwMilliseconds, int dwWakeMask);
//调用时SetWaitableTimer 那里开始出错...程序的作用是一个精确到微秒的等待.不知不用API,C#里是否有自己带的涵数
        public void gjdwait(int weimiao)
        {
            int hTimer;
            LARGE_INTEGER int65=new LARGE_INTEGER ();
            
            int65.QuadPart = -10 * weimiao;
            hTimer =CreateWaitableTimerA (0,false ,0);
            SetWaitableTimer(hTimer, int65, 0, 0, 0, false);
            while (MsgWaitForMultipleObjects(1, hTimer, false, INFINITE, QS_ALLINPUT) != WAIT_OBJECT_0)
            {
                Application.DoEvents();
            }
            CloseHandle(hTimer);        }
查 
http://www.pinvoke.net 
原先API的声明 
[DllImport("kernel32.dll")] 
 static extern bool SetWaitableTimer(IntPtr hTimer, [In] ref long pDueTime, 
    int lPeriod, TimerCompleteDelegate pfnCompletionRoutine, 
    IntPtr lpArgToCompletionRoutine, bool fResume);          [DllImport("kernel32.dll")] 
         static extern IntPtr CreateWaitableTimer(IntPtr lpTimerAttributes, 
            bool bManualReset,int lpTimerName);          [DllImport("kernel32.dll", SetLastError = true)] 
         [return: MarshalAs(UnmanagedType.Bool)] 
         static extern bool CloseHandle(IntPtr hObject);          [DllImport("user32.dll")] 
         static extern uint MsgWaitForMultipleObjects(uint nCount, IntPtr[] pHandles, 
            bool bWaitAll, uint dwMilliseconds, uint dwWakeMask); 
希望有人能修正一下...
运行时说
 hTimer =CreateWaitableTimerA (0,false ,0);
栈的错.不知是不是 把原来API的参数改了就出错..