On Thu Apr 13 14:20:54 2023 +0000, Rémi Bernon wrote:
I don't know, this feels brittle. If something relies on being in the desktop window thread, or process, it should not run before the window is fully created, and calling `NtUserGetDesktopWindow()` is the way to make sure that it is. The desktop startup process is convoluted, and explorer may start multiple times until one of them becomes the desktop process. Maybe this process could be simplified but otherwise I think it's risky to try working around its limitation.
Fwiw, I don't know why you need to keep this in the desktop process only but maybe the solution is simply to not enforce that and let any process run this. The display setting cache mechanism should ensure that it's not unnecessarily done.