shell.hpp 5.9 KB

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