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.

203 lines
4.4 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. bkhlpfil.c
  5. Abstract:
  6. Routines to manipulate help files and help file names.
  7. Author:
  8. Ted Miller (tedm) 5-Jan-1995
  9. Revision History:
  10. --*/
  11. #include "books.h"
  12. #include <shellapi.h>
  13. //
  14. // Fixed name of the help file. This is dependent on whether
  15. // this is server or workstation and is set in FixupNames().
  16. //
  17. PWSTR HelpFileName;
  18. //
  19. // Path on CD-ROM where online books files are located.
  20. // We "just know" this value.
  21. //
  22. PWSTR PathOfBooksFilesOnCd = L"\\SUPPORT\\BOOKS";
  23. VOID
  24. FormHelpfilePaths(
  25. IN WCHAR Drive, OPTIONAL
  26. IN PWSTR Path,
  27. IN PWSTR FilenamePrepend, OPTIONAL
  28. OUT PWSTR Filename,
  29. OUT PWSTR Directory OPTIONAL
  30. )
  31. /*++
  32. Routine Description:
  33. Form the full pathname of the main online books help file
  34. and of the directory containing the help file (ie, the pathname
  35. of the help file without the filename part).
  36. The filename part of the name is determined by the server/workstation
  37. setting and is fixed.
  38. Arguments:
  39. Drive - if specified, supplies the drive letter of the drive
  40. on which the help file is located. If not specified, the
  41. file is assumed to be on a UNC or other path as described
  42. by Path.
  43. Path - supplies the path component of the location of the
  44. help file name. This can be relative to a drive (if Drive is specified)
  45. of a complete path component (Drive is not specified).
  46. FilenamePrepend - if specified, supplies a string to be prepended
  47. to the generated full pathname of the helpfile. This is useful
  48. when generating command lines.
  49. Filename - receives the full pathname of the help file. The caller must
  50. ensure that the buffer is large enough.
  51. Directory - if specified, receives the full path of the directory
  52. in which the helpfile is located. The caller must ensure that the
  53. buffer is large enough.
  54. Return Value:
  55. None.
  56. --*/
  57. {
  58. if(Drive) {
  59. wsprintf(
  60. Filename,
  61. L"%s%c:%s\\%s",
  62. FilenamePrepend ? FilenamePrepend : L"",
  63. Drive,
  64. Path,
  65. HelpFileName
  66. );
  67. if(Directory) {
  68. wsprintf(Directory,L"%c:%s",Drive,Path);
  69. }
  70. } else {
  71. wsprintf(
  72. Filename,
  73. L"%s%s\\%s",
  74. FilenamePrepend ? FilenamePrepend : L"",
  75. Path,
  76. HelpFileName
  77. );
  78. if(Directory) {
  79. lstrcpy(Directory,Path);
  80. }
  81. }
  82. }
  83. BOOL
  84. CheckHelpfilePresent(
  85. IN PWSTR Path
  86. )
  87. /*++
  88. Routine Description:
  89. Determine if the relevent helpfile (a fixed name depending on
  90. whether this is workstation or server) is accessible.
  91. Arguments:
  92. Path - supplies the path to the helpfile (a full path that does not
  93. include the filename part and should not end with a backslash).
  94. Return Value:
  95. Boolean value indicating whether the file is accessible.
  96. --*/
  97. {
  98. WCHAR Filename[MAX_PATH];
  99. FormHelpfilePaths(0,Path,NULL,Filename,NULL);
  100. return DoesFileExist(Filename);
  101. }
  102. VOID
  103. FireUpWinhelp(
  104. IN WCHAR Drive, OPTIONAL
  105. IN PWSTR Path
  106. )
  107. /*++
  108. Routine Description:
  109. Invoke winhlp32.exe on the relevent online books helpfile.
  110. This routine also stores the helpfile location in the
  111. application profile if winhlp32 could be successfully executed.
  112. Arguments:
  113. Drive - if specified, supplies the drive letter of the drive
  114. on which the help file is located. If not specified, the
  115. file is assumed to be on a UNC or other path as described
  116. by Path.
  117. Path - supplies the path component of the location of the
  118. help file name. This can be relative to a drive (if Drive is specified)
  119. of a complete path component (Drive is not specified).
  120. Return Value:
  121. None. If winhlp32 cannot be started a fatal error is generated
  122. and this routine does not return to its caller.
  123. --*/
  124. {
  125. WCHAR CommandLine[MAX_PATH];
  126. WCHAR CurrentDirectory[MAX_PATH];
  127. FormHelpfilePaths(
  128. Drive,
  129. Path,
  130. NULL,
  131. CommandLine,
  132. CurrentDirectory
  133. );
  134. if(((INT_PTR)ShellExecute(NULL, L"open", CommandLine, NULL, NULL, SW_SHOWNORMAL)) > 32) {
  135. //
  136. // Remember the location of the help file.
  137. //
  138. MySetProfileValue(BooksProfileLocation,CurrentDirectory);
  139. } else {
  140. MyError(NULL,IDS_CANT_START_WINHELP,TRUE);
  141. }
  142. }