I can use the following command to find out if a Windows Terminal Server is in Install Mode.
change user /query
How can I detect this programmatically through the Windows API?
It looks like there is no supported way to do it.
Kernel32.dll exports the required function, but the documentation discourages its use. Also, the documentation doesn't list an alternative.
BOOL TermsrvAppInstallMode(void);
http://msdn.microsoft.com/en-us/library/bb432494(v=VS.85).aspx