Leaked source code of windows server 2003
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.

54 lines
1.7 KiB

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