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.

61 lines
1.9 KiB

  1. #include "priv.h"
  2. // Do not build this file if on Win9X or NT4
  3. #ifndef DOWNLEVEL_PLATFORM
  4. //============================================================================
  5. // This file contains a bunch of Unicode/Ansi thunks to handle calling
  6. // some internal functions that on Windows 95 the strings are Ansi,
  7. // whereas the string on NT are unicode
  8. //============================================================================
  9. #define PFN_FIRSTTIME ((void *)-1)
  10. // First undefine everything that we are intercepting as to not forward back to us...
  11. #undef SHGetSpecialFolderPath
  12. // Explicit prototype because only the A/W prototypes exist in the headers
  13. STDAPI_(BOOL) SHGetSpecialFolderPath(HWND hwndOwner, LPTSTR lpszPath, int nFolder, BOOL fCreate);
  14. typedef BOOL (WINAPI * PFNGETSPECIALFOLDERPATH)(HWND hwndOwner, LPTSTR pwszPath, int nFolder, BOOL fCreate);
  15. BOOL _AorW_SHGetSpecialFolderPath(HWND hwndOwner, /*OUT*/ LPTSTR pszPath, int nFolder, BOOL fCreate)
  16. {
  17. // The classic shell exported a non-decorated SHGetSpecialFolderPath
  18. // that took TCHAR parameters. The IE4 shell exported additional
  19. // decorated versions. Try to use the explicit decorated versions if
  20. // we can.
  21. static PFNGETSPECIALFOLDERPATH s_pfn = PFN_FIRSTTIME;
  22. *pszPath = 0;
  23. if (PFN_FIRSTTIME == s_pfn)
  24. {
  25. HINSTANCE hinst = LoadLibraryA("SHELL32.DLL");
  26. if (hinst)
  27. {
  28. #ifdef UNICODE
  29. s_pfn = (PFNGETSPECIALFOLDERPATH)GetProcAddress(hinst, "SHGetSpecialFolderPathW");
  30. #else
  31. s_pfn = (PFNGETSPECIALFOLDERPATH)GetProcAddress(hinst, "SHGetSpecialFolderPathA");
  32. #endif
  33. }
  34. else
  35. s_pfn = NULL;
  36. }
  37. if (s_pfn)
  38. {
  39. return s_pfn(hwndOwner, pszPath, nFolder, fCreate);
  40. }
  41. else
  42. {
  43. return SHGetSpecialFolderPath(hwndOwner, pszPath, nFolder, fCreate);
  44. }
  45. }
  46. #endif //DOWNLEVEL_PLATFORM