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.

150 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. nicepath.c
  5. Abstract:
  6. This module is responsable for building an MemDb category holding paths. For each path there is
  7. a message id associated (the value of the key). We use this message ID to have a good looking
  8. report for links that have some problems.
  9. Author:
  10. Calin Negreanu (calinn) 01-May-1998
  11. Revision History:
  12. --*/
  13. #include "pch.h"
  14. /*++
  15. Macro Expansion List Description:
  16. NICE_PATHS lists a list of paths that we can translate for user in something nicer. For example Start Menu will
  17. be translated in something like "In your start menu" and so on.
  18. Line Syntax:
  19. DEFMAC(Key, MessageId, IsShellFolder)
  20. Arguments:
  21. Key - This is sort of key to get the message ID. If IsShellFolder is TRUE then this is the ValueName from ShellFolders key.
  22. If IsShellFolder is false then this is a well known path like Program Files.
  23. MessageId - This is the string that should replace the path that is identified by the Key.
  24. IsShellFolder - This is a boolean value that specifies if Key is a ValueName from ShellFolders key or a well known path
  25. Variables Generated From List:
  26. g_NicePaths
  27. For accessing the array there are the following functions:
  28. AddShellFolder
  29. InitGlobalPaths
  30. --*/
  31. PTSTR g_RunKeyDir = NULL;
  32. //
  33. // Declare the macro list of action functions
  34. //
  35. #define NICE_PATHS \
  36. DEFMAC("Desktop", MSG_NICE_PATH_DESKTOP, TRUE ) \
  37. DEFMAC("Programs", MSG_NICE_PATH_PROGRAMS, TRUE ) \
  38. DEFMAC("Start Menu", MSG_NICE_PATH_START_MENU, TRUE ) \
  39. DEFMAC("StartUp", MSG_NICE_PATH_START_UP, TRUE ) \
  40. DEFMAC("SendTo", MSG_NICE_PATH_SEND_TO, TRUE ) \
  41. DEFMAC("Favorites", MSG_NICE_PATH_FAVORITES, TRUE ) \
  42. DEFMAC("Recent", MSG_NICE_PATH_RECENT, TRUE ) \
  43. DEFMAC("Templates", MSG_NICE_PATH_TEMPLATES, TRUE ) \
  44. DEFMAC(&g_WinDir, MSG_NICE_PATH_WIN_DIR, FALSE) \
  45. DEFMAC(&g_ProgramFilesDir, MSG_NICE_PATH_PROGRAM_FILES, FALSE) \
  46. DEFMAC(&g_SystemDir, MSG_NICE_PATH_SYSTEM_DIR, FALSE) \
  47. DEFMAC(&g_RunKeyDir, MSG_NICE_PATH_RUN_KEY, FALSE) \
  48. typedef struct {
  49. PVOID Key;
  50. DWORD MessageId;
  51. BOOL IsShellFolder;
  52. } NICE_PATH_STRUCT, *PNICE_PATH_STRUCT;
  53. //
  54. // Declare a global array of functions and name identifiers for action functions
  55. //
  56. #define DEFMAC(key,id,test) {key, id, test},
  57. static NICE_PATH_STRUCT g_NicePaths[] = {
  58. NICE_PATHS
  59. {NULL, 0, FALSE}
  60. };
  61. #undef DEFMAC
  62. VOID
  63. InitGlobalPaths (
  64. VOID
  65. )
  66. {
  67. PNICE_PATH_STRUCT p;
  68. TCHAR key [MEMDB_MAX];
  69. USHORT priority = 1;
  70. g_RunKeyDir = DuplicatePathString (S_RUNKEYFOLDER, 0);
  71. p = g_NicePaths;
  72. while (p->Key != NULL) {
  73. if (!p->IsShellFolder) {
  74. MemDbBuildKey (key, MEMDB_CATEGORY_NICE_PATHS, (*(PCTSTR *)(p->Key)), NULL, NULL);
  75. MemDbSetValueAndFlags (key, p->MessageId, priority, 0);
  76. }
  77. p ++;
  78. priority ++;
  79. }
  80. FreePathString (g_RunKeyDir);
  81. g_RunKeyDir = NULL;
  82. }
  83. BOOL
  84. AddShellFolder (
  85. PCTSTR ValueName,
  86. PCTSTR FolderName
  87. )
  88. {
  89. PNICE_PATH_STRUCT p;
  90. TCHAR key [MEMDB_MAX];
  91. USHORT priority = 1;
  92. p = g_NicePaths;
  93. while (p->Key != NULL) {
  94. if ((p->IsShellFolder) &&
  95. (StringIMatch (ValueName, (PCTSTR)p->Key))
  96. ) {
  97. MemDbBuildKey (key, MEMDB_CATEGORY_NICE_PATHS, FolderName, NULL, NULL);
  98. MemDbSetValueAndFlags (key, p->MessageId, priority, 0);
  99. return TRUE;
  100. }
  101. p ++;
  102. priority ++;
  103. }
  104. return FALSE;
  105. }