Windows NT 4.0 source code leak
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.

77 lines
2.1 KiB

4 years ago
  1. #include <windows.h>
  2. #include <port1632.h>
  3. #include <stdlib.h>
  4. #include <direct.h>
  5. #include <string.h>
  6. CHAR szHelpFileName[_MAX_PATH];
  7. CHAR szHelp[] = "MSTEST.HLP";
  8. //---------------------------------------------------------------------------
  9. // SetHelpFileName
  10. //
  11. // This function is called on startup and creates a fully qualified path to
  12. // the help file.
  13. // 1. trys current working dir of app
  14. // 2. trys where module running from
  15. // 3. trys windows OpenFile search rules
  16. //
  17. // CHANGES:
  18. // szHelpFileName : full path or empty string if not found
  19. // RETURNS: Nothing
  20. //---------------------------------------------------------------------------
  21. VOID SetHelpFileName (VOID)
  22. {
  23. INT len; /* length of string */
  24. OFSTRUCT of; /* OpenFile structure */
  25. HFILE fh; /* file handle */
  26. /* brings in malloc code unnecessarily */
  27. _getcwd(szHelpFileName,sizeof(szHelpFileName));
  28. strcat(szHelpFileName,"\\");
  29. strcat(szHelpFileName,szHelp);
  30. if (MOpenFile(szHelpFileName, &of, OF_EXIST) != -1)
  31. return;
  32. len = GetModuleFileName (GetModuleHandle ("TESTDRVR"),
  33. szHelpFileName, sizeof(szHelpFileName));
  34. if (len > 0)
  35. {
  36. /* don't use basename of this, as maybe the exe has been
  37. ** renamed. Can't look under new name, as other apps
  38. ** (testscrn, testdlgs) must look for correct name
  39. */
  40. while (len >= 0 && szHelpFileName[len] != '\\' )
  41. len--;
  42. if (len != -1)
  43. {
  44. /* found a slash */
  45. strcpy(&szHelpFileName[len+1],szHelp);
  46. if (MOpenFile(szHelpFileName, &of, OF_EXIST) != -1)
  47. return;
  48. }
  49. }
  50. /* OF_PARSE doesn't find the file on the path like I would
  51. ** expect. Oh, well, open it and close it.
  52. */
  53. if ((fh = MOpenFile(szHelp, &of, OF_READ | OF_SHARE_DENY_NONE)) != -1)
  54. {
  55. M_lclose(fh);
  56. /* found it, save it */
  57. OemToAnsi(of.szPathName,szHelpFileName);
  58. return;
  59. }
  60. /* exhausted all possibilities to find the file */
  61. szHelpFileName[0] = 0; /* no help file */
  62. return;
  63. }