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.

85 lines
1.9 KiB

  1. /*****************************************************************************************************************
  2. FILENAME: Exclude.cpp
  3. COPYRIGHT 2001 Microsoft Corporation and Executive Software International, Inc.
  4. */
  5. #include "stdafx.h"
  6. #ifndef SNAPIN
  7. #include <windows.h>
  8. #endif
  9. #include "ErrMacro.h"
  10. #include "expand.h"
  11. #include <tchar.h>
  12. /****************************************************************************************************************
  13. COPYRIGHT 2001 Microsoft Corporation and Executive Software International, Inc.
  14. ROUTINE DESCRIPTION:
  15. Checks for an environment parameters in the string, and if found, replaces them with the
  16. non-logical value of the environment parameters.
  17. INPUT + OUTPUT:
  18. IN OUT pString - The string that may contain the environment parameter.
  19. GLOBALS:
  20. None.
  21. RETURN:
  22. TRUE - Success.
  23. FALSE - Fatal error.
  24. */
  25. BOOL
  26. ExpandEnvVars(
  27. IN OUT TCHAR * pString // should be at least MAX_PATH characters long
  28. )
  29. {
  30. TCHAR szOriginalString[MAX_PATH+1];
  31. DWORD cchSize = 0;
  32. if (!pString || (_tcslen(pString) >= MAX_PATH)) {
  33. return FALSE;
  34. }
  35. _tcsncpy(szOriginalString, pString, MAX_PATH);
  36. szOriginalString[MAX_PATH] = TEXT('\0');
  37. cchSize = ExpandEnvironmentStrings(szOriginalString, pString, MAX_PATH);
  38. if ((0 == cchSize) || (cchSize > MAX_PATH)) {
  39. return FALSE;
  40. }
  41. return TRUE;
  42. }
  43. LPTSTR
  44. GetHelpFilePath()
  45. {
  46. static TCHAR szHelpFilePath[MAX_PATH + 20];
  47. static BOOL bReset = TRUE;
  48. if (bReset) {
  49. ZeroMemory(szHelpFilePath, sizeof(TCHAR) * (MAX_PATH + 20));
  50. if (0 == GetSystemWindowsDirectory(szHelpFilePath, MAX_PATH + 1)) {
  51. szHelpFilePath[0] = TEXT('\0');
  52. }
  53. _tcscat(szHelpFilePath, TEXT("\\Help\\Defrag.HLP"));
  54. //TODO: Check if file exists?
  55. bReset = FALSE;
  56. }
  57. return szHelpFilePath;
  58. }