murrayju / CreateProcessAsUser

Creates a process in a different Windows session
MIT License
369 stars 114 forks source link

MainWindowHandle and MainWindowTitle always 0/null #41

Open Light407 opened 3 weeks ago

Light407 commented 3 weeks ago

First of all thanks for a great lib, really works great!

We modified this lib a bit in order to start an GUI application minimized from a Windows Service, we used the following line and it seems to work:

startInfo.wShowWindow = (short)SW.SW_SHOWMINIMIZED;

Before finding out we could modify it this way I was trying a wide range of methods in order to call ShowWindow with value 6 (Minimize) to minimize to main window upon start but I tried 3-4 different Windows invoke calls such as EnumWindows, FindWindow, MainWindowHandle prop etc but all methods I could find was returning 0 for MainWindowHandle trying to find the Window for the started application and minimize it. Really strange, when I found out I could do above I gave up on doing it with ShowWindow.

Has anyone encountered this issue and/or solved it? Interested in knowing why this is happening.