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