G
Guest
I find some source code in MSDN. These code is used to detect whether terminal services is installed in windows
I known terminal services is install in WindowsXP Pro. However, when I run these code in windowsXP Pro, the result is the terminal services isn't install. Why
The following is the source code in MSDN
First
BOOL AreWeRunningTerminalServices(void
OSVERSIONINFOEX osVersionInfo
DWORDLONG dwlConditionMask = 0
ZeroMemory(&osVersionInfo, sizeof(OSVERSIONINFOEX))
osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX)
osVersionInfo.wSuiteMask = VER_SUITE_TERMINAL
VER_SET_CONDITION( dwlConditionMask, VER_SUITENAME, VER_AND )
return VerifyVersionInfo
&osVersionInfo
VER_SUITENAME
dwlConditionMas
)
Secode
#include <windows.h
#include <winbase.h
/* ------------------------------------------------------------
Note that the ValidateProductSuite and IsTerminalService
functions use ANSI versions of the functions to maintai
compatibility with Windows 95/98/Me
------------------------------------------------------------- *
BOOL ValidateProductSuite (LPSTR lpszSuiteToValidate)
BOOL IsTerminalServicesEnabled( VOID )
BOOL bResult = FALSE
DWORD dwVersion
OSVERSIONINFOEXA osVersion
DWORDLONG dwlCondition = 0
HMODULE hmodK32 = NULL
HMODULE hmodNtDll = NULL
typedef ULONGLONG (WINAPI *PFnVerSetCondition) (ULONGLONG, ULONG, UCHAR)
typedef BOOL (WINAPI *PFnVerifyVersionA) (POSVERSIONINFOEXA, DWORD, DWORDLONG)
PFnVerSetCondition pfnVerSetCondition
PFnVerifyVersionA pfnVerifyVersionA
dwVersion = GetVersion()
// Are we running Windows NT
if (!(dwVersion & 0x80000000))
// Is it Windows 2000 or greater
if (LOBYTE(LOWORD(dwVersion)) > 4)
// On Windows 2000 and later, use the VerifyVersionInfo and
// VerSetConditionMask functions. Don't static link because
// it won't load on earlier systems
hmodNtDll = GetModuleHandleA( "ntdll.dll" )
if (hmodNtDll)
pfnVerSetCondition = (PFnVerSetCondition) GetProcAddress(
hmodNtDll, "VerSetConditionMask")
if (pfnVerSetCondition != NULL)
dwlCondition = (*pfnVerSetCondition) (dwlCondition,
VER_SUITENAME, VER_AND)
// Get a VerifyVersionInfo pointer
hmodK32 = GetModuleHandleA( "KERNEL32.DLL" )
if (hmodK32 != NULL)
pfnVerifyVersionA = (PFnVerifyVersionA) GetProcAddress
hmodK32, "VerifyVersionInfoA")
if (pfnVerifyVersionA != NULL)
ZeroMemory(&osVersion, sizeof(osVersion))
osVersion.dwOSVersionInfoSize = sizeof(osVersion)
osVersion.wSuiteMask = VER_SUITE_TERMINAL
bResult = (*pfnVerifyVersionA) (&osVersion
VER_SUITENAME, dwlCondition)
else // This is Windows NT 4.0 or earlier
bResult = ValidateProductSuite( "Terminal Server" )
return bResult
///////////////////////////////////////////////////////////
// ValidateProductSuite functio
/
// Terminal Services detection code for systems runnin
// Windows NT 4.0 and earlier
/
///////////////////////////////////////////////////////////
BOOL ValidateProductSuite (LPSTR lpszSuiteToValidate)
BOOL fValidated = FALSE
LONG lResult
HKEY hKey = NULL
DWORD dwType = 0
DWORD dwSize = 0
LPSTR lpszProductSuites = NULL
LPSTR lpszSuite
// Open the ProductOptions key
lResult = RegOpenKeyA
HKEY_LOCAL_MACHINE
"System\\CurrentControlSet\\Control\\ProductOptions"
&hKe
)
if (lResult != ERROR_SUCCESS
goto exit
// Determine required size of ProductSuite buffer
lResult = RegQueryValueExA( hKey, "ProductSuite", NULL, &dwType,
NULL, &dwSize )
if (lResult != ERROR_SUCCESS || !dwSize
goto exit
// Allocate buffer
lpszProductSuites = (LPSTR) LocalAlloc( LPTR, dwSize )
if (!lpszProductSuites)
goto exit;
// Retrieve array of product suite strings.
lResult = RegQueryValueExA( hKey, "ProductSuite", NULL, &dwType,
(LPBYTE) lpszProductSuites, &dwSize );
if (lResult != ERROR_SUCCESS || dwType != REG_MULTI_SZ)
goto exit;
// Search for suite name in array of strings.
lpszSuite = lpszProductSuites;
while (*lpszSuite)
{
if (lstrcmpA( lpszSuite, lpszSuiteToValidate ) == 0)
{
fValidated = TRUE;
break;
}
lpszSuite += (lstrlenA( lpszSuite ) + 1);
}
exit:
if (lpszProductSuites)
LocalFree( lpszProductSuites );
if (hKey)
RegCloseKey( hKey );
return fValidated;
}
I known terminal services is install in WindowsXP Pro. However, when I run these code in windowsXP Pro, the result is the terminal services isn't install. Why
The following is the source code in MSDN
First
BOOL AreWeRunningTerminalServices(void
OSVERSIONINFOEX osVersionInfo
DWORDLONG dwlConditionMask = 0
ZeroMemory(&osVersionInfo, sizeof(OSVERSIONINFOEX))
osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX)
osVersionInfo.wSuiteMask = VER_SUITE_TERMINAL
VER_SET_CONDITION( dwlConditionMask, VER_SUITENAME, VER_AND )
return VerifyVersionInfo
&osVersionInfo
VER_SUITENAME
dwlConditionMas
)
Secode
#include <windows.h
#include <winbase.h
/* ------------------------------------------------------------
Note that the ValidateProductSuite and IsTerminalService
functions use ANSI versions of the functions to maintai
compatibility with Windows 95/98/Me
------------------------------------------------------------- *
BOOL ValidateProductSuite (LPSTR lpszSuiteToValidate)
BOOL IsTerminalServicesEnabled( VOID )
BOOL bResult = FALSE
DWORD dwVersion
OSVERSIONINFOEXA osVersion
DWORDLONG dwlCondition = 0
HMODULE hmodK32 = NULL
HMODULE hmodNtDll = NULL
typedef ULONGLONG (WINAPI *PFnVerSetCondition) (ULONGLONG, ULONG, UCHAR)
typedef BOOL (WINAPI *PFnVerifyVersionA) (POSVERSIONINFOEXA, DWORD, DWORDLONG)
PFnVerSetCondition pfnVerSetCondition
PFnVerifyVersionA pfnVerifyVersionA
dwVersion = GetVersion()
// Are we running Windows NT
if (!(dwVersion & 0x80000000))
// Is it Windows 2000 or greater
if (LOBYTE(LOWORD(dwVersion)) > 4)
// On Windows 2000 and later, use the VerifyVersionInfo and
// VerSetConditionMask functions. Don't static link because
// it won't load on earlier systems
hmodNtDll = GetModuleHandleA( "ntdll.dll" )
if (hmodNtDll)
pfnVerSetCondition = (PFnVerSetCondition) GetProcAddress(
hmodNtDll, "VerSetConditionMask")
if (pfnVerSetCondition != NULL)
dwlCondition = (*pfnVerSetCondition) (dwlCondition,
VER_SUITENAME, VER_AND)
// Get a VerifyVersionInfo pointer
hmodK32 = GetModuleHandleA( "KERNEL32.DLL" )
if (hmodK32 != NULL)
pfnVerifyVersionA = (PFnVerifyVersionA) GetProcAddress
hmodK32, "VerifyVersionInfoA")
if (pfnVerifyVersionA != NULL)
ZeroMemory(&osVersion, sizeof(osVersion))
osVersion.dwOSVersionInfoSize = sizeof(osVersion)
osVersion.wSuiteMask = VER_SUITE_TERMINAL
bResult = (*pfnVerifyVersionA) (&osVersion
VER_SUITENAME, dwlCondition)
else // This is Windows NT 4.0 or earlier
bResult = ValidateProductSuite( "Terminal Server" )
return bResult
///////////////////////////////////////////////////////////
// ValidateProductSuite functio
/
// Terminal Services detection code for systems runnin
// Windows NT 4.0 and earlier
/
///////////////////////////////////////////////////////////
BOOL ValidateProductSuite (LPSTR lpszSuiteToValidate)
BOOL fValidated = FALSE
LONG lResult
HKEY hKey = NULL
DWORD dwType = 0
DWORD dwSize = 0
LPSTR lpszProductSuites = NULL
LPSTR lpszSuite
// Open the ProductOptions key
lResult = RegOpenKeyA
HKEY_LOCAL_MACHINE
"System\\CurrentControlSet\\Control\\ProductOptions"
&hKe
)
if (lResult != ERROR_SUCCESS
goto exit
// Determine required size of ProductSuite buffer
lResult = RegQueryValueExA( hKey, "ProductSuite", NULL, &dwType,
NULL, &dwSize )
if (lResult != ERROR_SUCCESS || !dwSize
goto exit
// Allocate buffer
lpszProductSuites = (LPSTR) LocalAlloc( LPTR, dwSize )
if (!lpszProductSuites)
goto exit;
// Retrieve array of product suite strings.
lResult = RegQueryValueExA( hKey, "ProductSuite", NULL, &dwType,
(LPBYTE) lpszProductSuites, &dwSize );
if (lResult != ERROR_SUCCESS || dwType != REG_MULTI_SZ)
goto exit;
// Search for suite name in array of strings.
lpszSuite = lpszProductSuites;
while (*lpszSuite)
{
if (lstrcmpA( lpszSuite, lpszSuiteToValidate ) == 0)
{
fValidated = TRUE;
break;
}
lpszSuite += (lstrlenA( lpszSuite ) + 1);
}
exit:
if (lpszProductSuites)
LocalFree( lpszProductSuites );
if (hKey)
RegCloseKey( hKey );
return fValidated;
}