ホテル管理システム
ogi
yesterday 1a1c8e71fcd14858f595029f089b2d4a00202b32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.Diagnostics;
using System.Runtime.InteropServices;
 
namespace HotelPms.Share.Util
{
    public class SystemCommon
    {
        [DllImport("user32.dll", SetLastError = true)]
        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
 
        /// <summary> 待ち
        /// </summary>
        /// <param name="milliseconds"></param>
        public static void Wait(double milliseconds)
        {
            DateTime t = DateTime.Now.AddMilliseconds(milliseconds);
            while (DateTime.Now < t)
            {
                Thread.Sleep(1);
                if (DateTime.Now.AddMilliseconds(milliseconds + 1000) < t) { break; }  //途中でシステム時間変わった!!
            }
        }
 
        //public static void WaitDisktop()
        //{
        //    // wait until desktop ready
        //    IntPtr lHwnd = IntPtr.Zero;
        //    do
        //    {
        //        lHwnd = FindWindow("Shell_TrayWnd", null);
        //        Thread.Sleep(100);
        //    } while (lHwnd == IntPtr.Zero);
        //}
 
        public static void WaitDisktop()
        {
            while (true)
            {
                if (Process.GetProcessesByName("winlogon").Length > 0 && Process.GetProcessesByName("explorer").Length > 0)
                {
                    break;
                }
                Thread.Sleep(1);
            }
        }
    }
}