Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.9 KiB

  1. // Copyright (c) 1998 - 1999 Microsoft Corporation
  2. #include <windows.h>
  3. #include <winbase.h>
  4. typedef BOOLEAN (*PFnTERMSRVAPPINSTALLMODE) (VOID);
  5. typedef BOOLEAN (*PFnCTXGETINIMAPPING) (VOID);
  6. BOOL IsTrmSrvInstallMode()
  7. {
  8. BOOLEAN bReturn = FALSE;
  9. BOOL bReturn2 = FALSE;
  10. HINSTANCE hKernel = NULL;
  11. PFnTERMSRVAPPINSTALLMODE pfnTermsrvAppInstallMode = NULL;
  12. PFnCTXGETINIMAPPING pfnCtxGetIniMapping = NULL;
  13. hKernel = GetModuleHandleA("kernel32.dll");
  14. if (hKernel)
  15. {
  16. // Try to get the NT5 API first...
  17. pfnTermsrvAppInstallMode = (PFnTERMSRVAPPINSTALLMODE)GetProcAddress( hKernel, "TermsrvAppInstallMode");
  18. if ( pfnTermsrvAppInstallMode )
  19. {
  20. bReturn = pfnTermsrvAppInstallMode();
  21. }
  22. else
  23. {
  24. // No NT5 API ==> try the NT40-WTSRV API.
  25. // NOTE: Remember this API's output is reverse of the above API
  26. pfnCtxGetIniMapping = (PFnCTXGETINIMAPPING)GetProcAddress(hKernel,"CtxGetIniMapping");
  27. if (pfnCtxGetIniMapping)
  28. {
  29. bReturn = !pfnCtxGetIniMapping();
  30. }
  31. }
  32. }
  33. return bReturn;
  34. }
  35. int WINAPI WinMain(
  36. HINSTANCE hInstance, // handle to current instance
  37. HINSTANCE hPrevInstance, // handle to previous instance
  38. LPSTR lpCmdLine, // pointer to command line
  39. int nCmdShow // show state of window);
  40. )
  41. {
  42. BOOL bIsInstallMode;
  43. UNREFERENCED_PARAMETER (hInstance);
  44. UNREFERENCED_PARAMETER (hPrevInstance);
  45. UNREFERENCED_PARAMETER (lpCmdLine);
  46. UNREFERENCED_PARAMETER (nCmdShow);
  47. bIsInstallMode = IsTrmSrvInstallMode();
  48. if (bIsInstallMode)
  49. MessageBoxA( NULL, "TS Install Mode.", "Status", MB_OK );
  50. else
  51. MessageBoxA( NULL, "TS Execute Mode.", "Status", MB_OK );
  52. return 0;
  53. }