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.

55 lines
1.1 KiB

  1. //
  2. // wraps.cpp - wrapper functions for apis
  3. //
  4. #include "stdafx.h"
  5. #include "cmponent.h"
  6. #define DONT_WANT_SHELLDEBUG
  7. #include "shlobjp.h" // LPITEMIDLIST
  8. #if _WIN32_IE >= 0x0400
  9. //
  10. // Wrapper unnecessary for WIN64
  11. //
  12. #else
  13. //
  14. // We need this wrapper for ILCreateFromPath since it was a TCHAR exported by ordinal
  15. // on NT4 and now has A/W versions on NT5. Since we want to be able to run on both of
  16. // these platforms we wrap the API here.
  17. //
  18. // This api just loads shell32, and calls ordinal 157 which is the old TCHAR export
  19. //
  20. typedef LPITEMIDLIST (__stdcall *PFNILCREATEFROMPATH)(LPCTSTR pszPath);
  21. STDAPI_(LPITEMIDLIST) Wrap_ILCreateFromPath(LPCWSTR pszPath)
  22. {
  23. static PFNILCREATEFROMPATH pfn = (PFNILCREATEFROMPATH)-1;
  24. if (pfn == (PFNILCREATEFROMPATH)-1)
  25. {
  26. HINSTANCE hinst = LoadLibrary(TEXT("shell32.dll"));
  27. if (hinst)
  28. {
  29. pfn = (PFNILCREATEFROMPATH) GetProcAddress(hinst, (LPCSTR)157);
  30. }
  31. else
  32. {
  33. pfn = NULL;
  34. }
  35. }
  36. if (pfn)
  37. {
  38. return pfn(pszPath);
  39. }
  40. // If we failed for some reason, just return NULL
  41. return NULL;
  42. }
  43. #endif