shell.hpp 5.9 KB

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