I've been trying to detect whether or no the Terminal Services are running. I tried to use MSDN Way:
OSVERSIONINFOEX osVersionInfo;
DWORDLONG dwlConditionMask = 0;
memset( &osVersionInfo, 0, sizeof( osVersionInfo ) );
osVersionInfo.dwOSVersionInfoSize = sizeof( osVersionInfo );
osVersionInfo.wSuiteMask = VER_SUITE_TERMINAL;
VER_SET_CONDITION( dwlConditionMask, VER_SUITENAME, VER_AND );
return VerifyVersionInfo( &osVersionInfo, VER_SUITENAME, dwlConditionMask );
It works well, but on:
OS Name: Microsoft(R) Windows(R) Server 2003, Enterprise Edition
OS Version: 5.2.3790 Service Pack 2 Build 3790
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Server
OS Build Type: Multiprocessor Free
without Terminal Services role, call to VerifyVersionInfo returns non-zero value which means "the currently running operating system satisfies the specified requirements" or the function fails.
GetLastError returns:
0x000000cb "The system could not find the environment option that was entered."
On Windows XP SP3 call to VerifyVersionInfo returns zero value, so there are no typing errors, I suppose.
The question is: how to handle this behavior? Is it good to treat this as there are no Terminal Services? Are there any better techniques?
Is it a bug in OS?
Update: On Windows Server 2008 R1 behavior is similar (fails). May be on many other systems too.