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.

114 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. BaanERP5.cpp
  5. Abstract:
  6. Set 'lpstrInitialDir' in the OPENFILENAMEA structure passed to
  7. GetSaveFileNameA to be the directory the app is installed to.
  8. This information is read from the registry.
  9. No idea why this worked in Win9x.
  10. Notes:
  11. This is an app specific shim.
  12. History:
  13. 02/16/2000 clupu Created
  14. --*/
  15. #include "precomp.h"
  16. #include <commdlg.h>
  17. IMPLEMENT_SHIM_BEGIN(BaanERP5)
  18. #include "ShimHookMacro.h"
  19. APIHOOK_ENUM_BEGIN
  20. APIHOOK_ENUM_ENTRY(GetSaveFileNameA)
  21. APIHOOK_ENUM_END
  22. char gszLibUser[] = "\\LIB\\USER";
  23. char gszBaanDir[MAX_PATH];
  24. /*++
  25. Set the initial directory to be the directory the app was installed to. This
  26. information is read from the registry.
  27. --*/
  28. BOOL
  29. APIHOOK(GetSaveFileNameA)(
  30. LPOPENFILENAMEA lpofn
  31. )
  32. {
  33. if (lpofn->lpstrInitialDir == NULL) {
  34. HKEY hkey = NULL;
  35. DWORD ret;
  36. DWORD cbSize;
  37. /*
  38. * Get the directory only once
  39. */
  40. if (gszBaanDir[0] == 0) {
  41. ret = RegOpenKeyA(HKEY_LOCAL_MACHINE,
  42. "SOFTWARE\\Baan\\bse",
  43. &hkey);
  44. if (ret != ERROR_SUCCESS) {
  45. DPFN( eDbgLevelInfo, "Failed to open key 'SOFTWARE\\Baan\\bse'");
  46. goto Cont;
  47. }
  48. cbSize = MAX_PATH;
  49. ret = (DWORD)RegQueryValueExA(hkey,
  50. "BSE",
  51. NULL,
  52. NULL,
  53. (LPBYTE)gszBaanDir,
  54. &cbSize);
  55. if (ret != ERROR_SUCCESS) {
  56. DPFN( eDbgLevelInfo, "Failed to query value BSE");
  57. goto Cont;
  58. }
  59. lstrcatA(gszBaanDir, gszLibUser);
  60. Cont:
  61. if (hkey != NULL) {
  62. RegCloseKey(hkey);
  63. }
  64. }
  65. lpofn->lpstrInitialDir = gszBaanDir;
  66. DPFN( eDbgLevelInfo, "BaanERP5.dll, Changing lpstrInitialDir to '%s'", gszBaanDir);
  67. }
  68. // Call the Initial function
  69. return ORIGINAL_API(GetSaveFileNameA)(lpofn);
  70. }
  71. /*++
  72. Register hooked functions
  73. --*/
  74. HOOK_BEGIN
  75. APIHOOK_ENTRY(COMDLG32.DLL, GetSaveFileNameA)
  76. HOOK_END
  77. IMPLEMENT_SHIM_END