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.

89 lines
1.9 KiB

  1. //
  2. // MODULE: VersionInfo.CPP
  3. // PURPOSE This module reads version info from the resource file.
  4. // PROJECT: Generic Troubleshooter DLL for Microsoft AnswerPoint
  5. //
  6. // COMPANY: Saltmine Creative, Inc. (206)-284-7511 [email protected]
  7. //
  8. // AUTHOR: Oleg Kalosha
  9. //
  10. // ORIGINAL DATE:
  11. //
  12. // NOTES:
  13. // 1. Took it from Argon Project.
  14. //
  15. // Version Date By Comments
  16. //--------------------------------------------------------------------
  17. // V3.0 OK
  18. //
  19. #pragma warning(disable:4786)
  20. #include "stdafx.h"
  21. #include "VersionInfo.h"
  22. //
  23. LPCWSTR FindStr(LPCWSTR wszString, LPCWSTR wszCharSet, const DWORD dwStringLen)
  24. {
  25. LPCWSTR wszRetStr = NULL;
  26. int x;
  27. int SetLen;
  28. DWORD dwCheck = 0;
  29. DWORD dwCur = 0;
  30. if (NULL != wszCharSet && NULL != wszString)
  31. {
  32. SetLen = wcslen(wszCharSet);
  33. do
  34. {
  35. for (x = 0; x < SetLen; x++)
  36. {
  37. if (wszString[dwCheck] != wszCharSet[x])
  38. break;
  39. dwCheck++;
  40. }
  41. if (x == SetLen)
  42. {
  43. wszRetStr = &wszString[dwCur];
  44. break;
  45. }
  46. else
  47. {
  48. dwCur++;
  49. dwCheck = dwCur;
  50. }
  51. } while (dwCur < dwStringLen);
  52. }
  53. return wszRetStr;
  54. }
  55. LPCWSTR GetVersionInfo(HINSTANCE hInst, LPWSTR wszStrName)
  56. {
  57. LPCWSTR pwszFileVersion;
  58. LPCWSTR pwszStrInfo = NULL;
  59. LPWSTR pwszVerInfo = NULL;
  60. DWORD dwDataLen = 0;
  61. LPCTSTR lpName = (LPTSTR) VS_VERSION_INFO;
  62. HRSRC hVerInfo = FindResource(hInst, lpName, RT_VERSION);
  63. if (NULL != hVerInfo)
  64. {
  65. HGLOBAL hVer = LoadResource(hInst, hVerInfo);
  66. if (NULL != hVer)
  67. {
  68. pwszVerInfo = (LPWSTR) LockResource(hVer);
  69. if (NULL != pwszVerInfo)
  70. {
  71. dwDataLen = SizeofResource(hInst, hVerInfo);
  72. if (NULL != (pwszFileVersion = FindStr(pwszVerInfo, wszStrName, dwDataLen / sizeof(WCHAR))))
  73. {
  74. pwszStrInfo = pwszFileVersion + wcslen(pwszFileVersion);
  75. while (NULL == *pwszStrInfo)
  76. pwszStrInfo++;
  77. }
  78. }
  79. }
  80. }
  81. return pwszStrInfo;
  82. }