Leaked source code of windows server 2003
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.

115 lines
2.9 KiB

  1. /****************************************************************************/
  2. // version.c
  3. //
  4. // TermSrv version setting functions.
  5. //
  6. // Copyright (C) 1997-2000 Microsoft Corporation
  7. /****************************************************************************/
  8. #include "precomp.h"
  9. #pragma hdrstop
  10. /*=============================================================================
  11. == Vars
  12. =============================================================================*/
  13. PWCHAR pProductOemInfo[] = {
  14. REG_CITRIX_OEMID,
  15. REG_CITRIX_OEMNAME,
  16. REG_CITRIX_PRODUCTNAME,
  17. REG_CITRIX_PRODUCTVERSION,
  18. (PWCHAR) NULL,
  19. };
  20. /*******************************************************************************
  21. // UpdateOemAndProductInfo
  22. //
  23. // Updates the registry with the OEM and Product info from SHELL32.DLL.
  24. // Called at init time. hKeyTermSrv is an open reg handle to
  25. // HKLM\Sys\CCS\Ctrl\TS TermSrv key. Returns FALSE on error.
  26. ******************************************************************************/
  27. BOOL UpdateOemAndProductInfo(HKEY hKeyTermSrv)
  28. {
  29. ULONG i;
  30. PWCHAR pInfo = NULL;
  31. DWORD dwSize;
  32. PCHAR pBuffer;
  33. DWORD dwBytes;
  34. PUSHORT pTransL;
  35. PUSHORT pTransH;
  36. WCHAR pString[255];
  37. PWCHAR pKey;
  38. BOOL bRc = TRUE;
  39. NTSTATUS Status;
  40. ASSERT(hKeyTermSrv != NULL);
  41. // Get the VersionInfo data: Determine size, alloc memory, then get it.
  42. dwSize = GetFileVersionInfoSize(OEM_AND_PRODUCT_INFO_DLL, 0);
  43. if (dwSize != 0) {
  44. pInfo = MemAlloc(dwSize);
  45. if (pInfo != NULL) {
  46. bRc = GetFileVersionInfo(OEM_AND_PRODUCT_INFO_DLL, 0, dwSize,
  47. pInfo);
  48. if (!bRc)
  49. goto done;
  50. }
  51. else {
  52. bRc = FALSE;
  53. goto done;
  54. }
  55. }
  56. else {
  57. bRc = FALSE;
  58. goto done;
  59. }
  60. /*
  61. * Get the translation information
  62. */
  63. if (!VerQueryValue(pInfo, L"\\VarFileInfo\\Translation", &pBuffer, &dwBytes)) {
  64. bRc = FALSE;
  65. goto done;
  66. }
  67. /*
  68. * Get the language and character set
  69. */
  70. pTransL = (PUSHORT)pBuffer;
  71. pTransH = (PUSHORT)(pBuffer + 2);
  72. /*
  73. * Pull out the individual fields
  74. */
  75. i = 0;
  76. while ((pKey = pProductOemInfo[i++]) != NULL) {
  77. /*
  78. * Generate StringFileInfo entry
  79. */
  80. wsprintf(pString, L"\\StringFileInfo\\%04X%04X\\%s", *pTransL,
  81. *pTransH, pKey);
  82. /*
  83. * Pull entry
  84. */
  85. if (!VerQueryValue( pInfo, pString, &pBuffer, &dwBytes ) ) {
  86. bRc = FALSE;
  87. goto done;
  88. }
  89. /*
  90. * Write key value
  91. */
  92. RegSetValueEx(hKeyTermSrv, pKey, 0, REG_SZ, pBuffer, dwBytes * 2);
  93. }
  94. done:
  95. /*
  96. * Free memory
  97. */
  98. if (pInfo != NULL)
  99. MemFree(pInfo);
  100. return bRc;
  101. }