Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if Windows desktop is fully functional (loaded) c#

Tags:

c#

window

desktop

I am writing an application that runs on Windows logon but I want it to wait until the desktop is fully functional/loaded before it actually starts doing anything. Is there any way of working out when Windows has completely finished loading the desktop?

like image 704
PentaPenguin Avatar asked Oct 19 '25 19:10

PentaPenguin


1 Answers

Very old question but I needed the same. The following code seems to work:

        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        // wait until desktop ready

        IntPtr lHwnd = IntPtr.Zero;
        do
        {
            lHwnd = FindWindow("Shell_TrayWnd", null);
            Thread.Sleep(100);
        } while (lHwnd == IntPtr.Zero);
like image 127
Tom Wagener Avatar answered Oct 21 '25 10:10

Tom Wagener