ReactOS 0.4.15-dev-7942-gd23573b
shellext.cpp File Reference
#include <ntstatus.h>
#include <windef.h>
#include <ntndk.h>
#include <atlbase.h>
#include <atlcom.h>
#include <shellapi.h>
#include <shlobj.h>
#include <shobjidl.h>
#include <shellutils.h>
#include "wine/test.h"
Include dependency graph for shellext.cpp:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 

Functions

static HRESULT Initialize (CComPtr< IPersistFolder > &spFolder, LPCWSTR Path)
 
static void CreateObjectsFromPersistFolder ()
 
static void CreateDropTarget ()
 
static void CreateExtractIcon ()
 
 START_TEST (shellext)
 

Variables

static const CLSID CLSID_FontExt = { 0xBD84B380, 0x8CA2, 0x1069, { 0xAB, 0x1D, 0x08, 0x00, 0x09, 0x48, 0xF5, 0x34 } }
 
static DWORD g_WinVersion
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 9 of file shellext.cpp.

Function Documentation

◆ CreateDropTarget()

static void CreateDropTarget ( )
static

Definition at line 144 of file shellext.cpp.

145{
146 CComPtr<IDropTarget> spDropTarget;
147 HRESULT hr = CoCreateInstance(CLSID_FontExt, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IDropTarget, &spDropTarget));
149}
#define ok_hex(expression, result)
Definition: atltest.h:94
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
static const CLSID CLSID_FontExt
Definition: shellext.cpp:20
HRESULT hr
Definition: shlfolder.c:183
#define E_NOINTERFACE
Definition: winerror.h:2364
#define IID_PPV_ARG(Itype, ppType)

Referenced by START_TEST().

◆ CreateExtractIcon()

static void CreateExtractIcon ( )
static

Definition at line 151 of file shellext.cpp.

152{
154 {
155 CComPtr<IExtractIconA> spExtractIconA;
156 HRESULT hr = CoCreateInstance(CLSID_FontExt, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IExtractIconA, &spExtractIconA));
157 ok_hex(hr, S_OK);
158
159 CComPtr<IExtractIconW> spExtractIconW;
160 hr = CoCreateInstance(CLSID_FontExt, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IExtractIconW, &spExtractIconW));
161 ok_hex(hr, S_OK);
162 }
163 else
164 {
165 CComPtr<IExtractIconA> spExtractIconA;
166 HRESULT hr = CoCreateInstance(CLSID_FontExt, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IExtractIconA, &spExtractIconA));
168
169 CComPtr<IExtractIconW> spExtractIconW;
170 hr = CoCreateInstance(CLSID_FontExt, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IExtractIconW, &spExtractIconW));
172 }
173}
#define S_OK
Definition: intsafe.h:52
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
static DWORD g_WinVersion
Definition: shellext.cpp:21

Referenced by START_TEST().

◆ CreateObjectsFromPersistFolder()

static void CreateObjectsFromPersistFolder ( )
static

Definition at line 44 of file shellext.cpp.

45{
46 WCHAR Path[MAX_PATH] = { 0 };
47
48 CComPtr<IPersistFolder> spFolder;
49 HRESULT hr = CoCreateInstance(CLSID_FontExt, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IPersistFolder, &spFolder));
50 ok_hex(hr, S_OK);
51 if (!SUCCEEDED(hr))
52 return;
53
55 ok_hex(hr, S_OK);
56 if (FAILED(hr))
57 return;
58
59 // Initializing this in another folder fails
60 hr = Initialize(spFolder, Path);
62
64 ok_hex(hr, S_OK);
65 if (FAILED(hr))
66 return;
67
68 // Initializing it in the font folder works
69 hr = Initialize(spFolder, Path);
70 ok_hex(hr, S_OK);
71
72 // For ros we do not implement the ShellView, but go directly to the ShellFolder.
73 // So we detect this special case
75 {
76 CComPtr<IShellFolder> spShellFolder;
77 hr = spFolder->QueryInterface(IID_PPV_ARG(IShellFolder, &spShellFolder));
78
79 if (SUCCEEDED(hr))
80 {
81 trace("Got IShellFolder on < Vista, faking 0x601\n");
83 }
84 }
85
87 {
88 // A view is present
89 CComPtr<IShellView> spView;
90 hr = spFolder->QueryInterface(IID_PPV_ARG(IShellView, &spView));
91 ok_hex(hr, S_OK);
92
93 // No shell folder
94 CComPtr<IShellFolder> spShellFolder;
95 hr = spFolder->QueryInterface(IID_PPV_ARG(IShellFolder, &spShellFolder));
97
98 // Ask the view:
99 if (spView)
100 {
101 CComPtr<IObjectWithSite> spObjectWithSite;
102 hr = spView->QueryInterface(IID_PPV_ARG(IObjectWithSite, &spObjectWithSite));
104
105 CComPtr<IInternetSecurityManager> spISM;
108 }
109
110
111 CComPtr<IDropTarget> spDropTarget;
112 hr = spFolder->QueryInterface(IID_PPV_ARG(IDropTarget, &spDropTarget));
113 ok_hex(hr, S_OK);
114
115 CComPtr<IExtractIconW> spExtractIcon;
116 hr = spFolder->QueryInterface(IID_PPV_ARG(IExtractIconW, &spExtractIcon));
118 }
119 else
120 {
121 // Here we have a shell folder
122 CComPtr<IShellFolder> spShellFolder;
123 hr = spFolder->QueryInterface(IID_PPV_ARG(IShellFolder, &spShellFolder));
124 ok_hex(hr, S_OK);
125
126 // But no view anymore
127 CComPtr<IShellView> spView;
128 hr = spFolder->QueryInterface(IID_PPV_ARG(IShellView, &spView));
130 spView.Release();
131
132
133 CComPtr<IDropTarget> spDropTarget;
134 hr = spFolder->QueryInterface(IID_PPV_ARG(IDropTarget, &spDropTarget));
136
137 CComPtr<IExtractIconW> spExtractIcon;
138 hr = spFolder->QueryInterface(IID_PPV_ARG(IExtractIconW, &spExtractIcon));
140 }
141}
PRTL_UNICODE_STRING_BUFFER Path
#define trace
Definition: atltest.h:70
#define E_FAIL
Definition: ddrawi.h:102
#define MAX_PATH
Definition: compat.h:34
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2589
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define _WIN32_WINNT_WIN7
Definition: sdkddkver.h:28
#define CSIDL_FONTS
Definition: shlobj.h:2177
#define CSIDL_WINDOWS
Definition: shlobj.h:2193
static void Initialize()
Definition: xlate.c:212
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ Initialize()

static HRESULT Initialize ( CComPtr< IPersistFolder > &  spFolder,
LPCWSTR  Path 
)
static

Definition at line 24 of file shellext.cpp.

25{
26 CComHeapPtr<ITEMIDLIST> pidl;
27 CComPtr<IShellFolder> spDesktop;
28
29 HRESULT hr = SHGetDesktopFolder(&spDesktop);
30 ok_hex(hr, S_OK);
31 if (FAILED(hr))
32 return hr;
33
34 DWORD Attributes = 0, chEaten = 0;
35 hr = spDesktop->ParseDisplayName(NULL, NULL, (LPOLESTR)Path, &chEaten, &pidl, &Attributes);
36 ok_hex(hr, S_OK);
37 if (FAILED(hr))
38 return hr;
39
40 return spFolder->Initialize(pidl);
41}
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
unsigned long DWORD
Definition: ntddk_ex.h:95
static LPOLESTR
Definition: stg_prop.c:27
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes

◆ START_TEST()

START_TEST ( shellext  )

Definition at line 177 of file shellext.cpp.

178{
179 RTL_OSVERSIONINFOEXW rtlinfo = {0};
180
181 rtlinfo.dwOSVersionInfoSize = sizeof(rtlinfo);
183 g_WinVersion = (rtlinfo.dwMajorVersion << 8) | rtlinfo.dwMinorVersion;
184
185 trace("g_WinVersion=0x%x\n", g_WinVersion);
186
188
192
194}
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
static void CreateDropTarget()
Definition: shellext.cpp:144
static void CreateObjectsFromPersistFolder()
Definition: shellext.cpp:44
static void CreateExtractIcon()
Definition: shellext.cpp:151
ULONG dwMajorVersion
Definition: rtltypes.h:270
ULONG dwMinorVersion
Definition: rtltypes.h:271
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:269

Variable Documentation

◆ CLSID_FontExt

const CLSID CLSID_FontExt = { 0xBD84B380, 0x8CA2, 0x1069, { 0xAB, 0x1D, 0x08, 0x00, 0x09, 0x48, 0xF5, 0x34 } }
static

◆ g_WinVersion

DWORD g_WinVersion
static

Definition at line 21 of file shellext.cpp.

Referenced by CreateExtractIcon(), CreateObjectsFromPersistFolder(), and START_TEST().