shell.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // shell.hpp --------------------------------------------------------------//
  2. // Copyright 2016 Klemens D. Morgenstern
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // See http://www.boost.org/LICENSE_1_0.txt
  5. #ifndef BOOST_DETAIL_WINAPI_SHELL_HPP_
  6. #define BOOST_DETAIL_WINAPI_SHELL_HPP_
  7. #include <boost/detail/winapi/basic_types.hpp>
  8. #include <boost/detail/winapi/limits.hpp>
  9. #if defined( BOOST_USE_WINDOWS_H )
  10. #include <shellapi.h>
  11. #endif
  12. #ifdef BOOST_HAS_PRAGMA_ONCE
  13. #pragma once
  14. #endif
  15. #if !defined( BOOST_USE_WINDOWS_H )
  16. extern "C" {
  17. BOOST_DETAIL_WINAPI_DECLARE_HANDLE(HICON);
  18. #if !defined( BOOST_NO_ANSI_APIS )
  19. struct _SHFILEINFOA;
  20. #endif
  21. struct _SHFILEINFOW;
  22. #if !defined( BOOST_NO_ANSI_APIS )
  23. BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_PTR_ WINAPI SHGetFileInfoA(
  24. boost::detail::winapi::LPCSTR_ pszPath,
  25. boost::detail::winapi::DWORD_ dwFileAttributes,
  26. ::_SHFILEINFOA *psfinsigned,
  27. boost::detail::winapi::UINT_ cbFileInfons,
  28. boost::detail::winapi::UINT_ uFlags);
  29. #endif
  30. BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_PTR_ WINAPI SHGetFileInfoW(
  31. boost::detail::winapi::LPCWSTR_ pszPath,
  32. boost::detail::winapi::DWORD_ dwFileAttributes,
  33. ::_SHFILEINFOW *psfinsigned,
  34. boost::detail::winapi::UINT_ cbFileInfons,
  35. boost::detail::winapi::UINT_ uFlags);
  36. } // extern "C"
  37. #endif // !defined( BOOST_USE_WINDOWS_H )
  38. namespace boost {
  39. namespace detail {
  40. namespace winapi {
  41. typedef ::HICON HICON_;
  42. #if defined( BOOST_USE_WINDOWS_H )
  43. const DWORD_ SHGFI_ICON_ = SHGFI_ICON;
  44. const DWORD_ SHGFI_DISPLAYNAME_ = SHGFI_DISPLAYNAME;
  45. const DWORD_ SHGFI_TYPENAME_ = SHGFI_TYPENAME;
  46. const DWORD_ SHGFI_ATTRIBUTES_ = SHGFI_ATTRIBUTES;
  47. const DWORD_ SHGFI_ICONLOCATION_ = SHGFI_ICONLOCATION;
  48. const DWORD_ SHGFI_EXETYPE_ = SHGFI_EXETYPE;
  49. const DWORD_ SHGFI_SYSICONINDEX_ = SHGFI_SYSICONINDEX;
  50. const DWORD_ SHGFI_LINKOVERLAY_ = SHGFI_LINKOVERLAY;
  51. const DWORD_ SHGFI_SELECTED_ = SHGFI_SELECTED;
  52. const DWORD_ SHGFI_ATTR_SPECIFIED_ = SHGFI_ATTR_SPECIFIED;
  53. const DWORD_ SHGFI_LARGEICON_ = SHGFI_LARGEICON;
  54. const DWORD_ SHGFI_SMALLICON_ = SHGFI_SMALLICON;
  55. const DWORD_ SHGFI_OPENICON_ = SHGFI_OPENICON;
  56. const DWORD_ SHGFI_SHELLICONSIZE_ = SHGFI_SHELLICONSIZE;
  57. const DWORD_ SHGFI_PIDL_ = SHGFI_PIDL;
  58. const DWORD_ SHGFI_USEFILEATTRIBUTES_ = SHGFI_USEFILEATTRIBUTES;
  59. #else // defined( BOOST_USE_WINDOWS_H )
  60. const DWORD_ SHGFI_ICON_ = 0x000000100;
  61. const DWORD_ SHGFI_DISPLAYNAME_ = 0x000000200;
  62. const DWORD_ SHGFI_TYPENAME_ = 0x000000400;
  63. const DWORD_ SHGFI_ATTRIBUTES_ = 0x000000800;
  64. const DWORD_ SHGFI_ICONLOCATION_ = 0x000001000;
  65. const DWORD_ SHGFI_EXETYPE_ = 0x000002000;
  66. const DWORD_ SHGFI_SYSICONINDEX_ = 0x000004000;
  67. const DWORD_ SHGFI_LINKOVERLAY_ = 0x000008000;
  68. const DWORD_ SHGFI_SELECTED_ = 0x000010000;
  69. const DWORD_ SHGFI_ATTR_SPECIFIED_ = 0x000020000;
  70. const DWORD_ SHGFI_LARGEICON_ = 0x000000000;
  71. const DWORD_ SHGFI_SMALLICON_ = 0x000000001;
  72. const DWORD_ SHGFI_OPENICON_ = 0x000000002;
  73. const DWORD_ SHGFI_SHELLICONSIZE_ = 0x000000004;
  74. const DWORD_ SHGFI_PIDL_ = 0x000000008;
  75. const DWORD_ SHGFI_USEFILEATTRIBUTES_ = 0x000000010;
  76. #endif // defined( BOOST_USE_WINDOWS_H )
  77. // These constants are only declared for _WIN32_IE >= 0x0500. We don't set IE version
  78. // and 5.0 is the default version since NT4 SP6, so just define the constants unconditionally.
  79. const DWORD_ SHGFI_ADDOVERLAYS_ = 0x000000020;
  80. const DWORD_ SHGFI_OVERLAYINDEX_ = 0x000000040;
  81. typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SHFILEINFOA {
  82. HICON_ hIcon;
  83. int iIcon;
  84. DWORD_ dwAttributes;
  85. CHAR_ szDisplayName[MAX_PATH_];
  86. CHAR_ szTypeName[80];
  87. } SHFILEINFOA_;
  88. typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SHFILEINFOW {
  89. HICON_ hIcon;
  90. int iIcon;
  91. DWORD_ dwAttributes;
  92. WCHAR_ szDisplayName[MAX_PATH_];
  93. WCHAR_ szTypeName[80];
  94. } SHFILEINFOW_;
  95. #if !defined( BOOST_NO_ANSI_APIS )
  96. BOOST_FORCEINLINE DWORD_PTR_ SHGetFileInfoA(LPCSTR_ pszPath, DWORD_ dwFileAttributes, SHFILEINFOA_* psfinsigned, UINT_ cbFileInfons, UINT_ uFlags)
  97. {
  98. return ::SHGetFileInfoA(pszPath, dwFileAttributes, reinterpret_cast< ::_SHFILEINFOA* >(psfinsigned), cbFileInfons, uFlags);
  99. }
  100. BOOST_FORCEINLINE DWORD_PTR_ sh_get_file_info(LPCSTR_ pszPath, DWORD_ dwFileAttributes, SHFILEINFOA_* psfinsigned, UINT_ cbFileInfons, UINT_ uFlags)
  101. {
  102. return ::SHGetFileInfoA(pszPath, dwFileAttributes, reinterpret_cast< ::_SHFILEINFOA* >(psfinsigned), cbFileInfons, uFlags);
  103. }
  104. #endif // BOOST_NO_ANSI_APIS
  105. BOOST_FORCEINLINE DWORD_PTR_ SHGetFileInfoW(LPCWSTR_ pszPath, DWORD_ dwFileAttributes, SHFILEINFOW_* psfinsigned, UINT_ cbFileInfons, UINT_ uFlags)
  106. {
  107. return ::SHGetFileInfoW(pszPath, dwFileAttributes, reinterpret_cast< ::_SHFILEINFOW* >(psfinsigned), cbFileInfons, uFlags);
  108. }
  109. BOOST_FORCEINLINE DWORD_PTR_ sh_get_file_info(LPCWSTR_ pszPath, DWORD_ dwFileAttributes, SHFILEINFOW_* psfinsigned, UINT_ cbFileInfons, UINT_ uFlags)
  110. {
  111. return ::SHGetFileInfoW(pszPath, dwFileAttributes, reinterpret_cast< ::_SHFILEINFOW* >(psfinsigned), cbFileInfons, uFlags);
  112. }
  113. }
  114. }
  115. }
  116. #endif // BOOST_DETAIL_WINAPI_SHELL_HPP_