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); /// 待ち /// /// 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); } } } }