ReactOS  0.4.14-dev-838-g99f979d
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

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 }
const CLSID CLSID_FontExt
Definition: shellext.cpp:20
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
#define ok_hex(expression, result)
Definition: atltest.h:94
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325

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 }
const CLSID CLSID_FontExt
Definition: shellext.cpp:20
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
#define ok_hex(expression, result)
Definition: atltest.h:94
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
static DWORD g_WinVersion
Definition: shellext.cpp:21
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:59

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);
61  ok_hex(hr, E_FAIL);
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;
106  hr = spView->QueryInterface(IID_PPV_ARG(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 }
#define _WIN32_WINNT_WIN7
Definition: sdkddkver.h:28
const CLSID CLSID_FontExt
Definition: shellext.cpp:20
#define E_NOINTERFACE
Definition: winerror.h:2364
static HRESULT Initialize(CComPtr< IPersistFolder > &spFolder, LPCWSTR Path)
Definition: shellext.cpp:24
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_FONTS
Definition: shlobj.h:2030
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
#define ok_hex(expression, result)
Definition: atltest.h:94
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
smooth NULL
Definition: ftsmooth.c:416
#define CSIDL_WINDOWS
Definition: shlobj.h:2046
#define trace
Definition: atltest.h:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
static DWORD g_WinVersion
Definition: shellext.cpp:21
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:59
PRTL_UNICODE_STRING_BUFFER Path
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2087
#define SUCCEEDED(hr)
Definition: intsafe.h:57

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 hr
Definition: shlfolder.c:183
static LPOLESTR
Definition: stg_prop.c:27
#define ok_hex(expression, result)
Definition: atltest.h:94
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:59
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
PRTL_UNICODE_STRING_BUFFER Path

Referenced by CreateObjectsFromPersistFolder().

◆ 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 
193  CoUninitialize();
194 }
static void CreateDropTarget()
Definition: shellext.cpp:144
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:265
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
ULONG dwMinorVersion
Definition: rtltypes.h:267
static void CreateExtractIcon()
Definition: shellext.cpp:151
ULONG dwMajorVersion
Definition: rtltypes.h:266
smooth NULL
Definition: ftsmooth.c:416
static void CreateObjectsFromPersistFolder()
Definition: shellext.cpp:44
#define trace
Definition: atltest.h:70
static DWORD g_WinVersion
Definition: shellext.cpp:21
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002

Variable Documentation

◆ CLSID_FontExt

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

◆ g_WinVersion

DWORD g_WinVersion
static

Definition at line 21 of file shellext.cpp.

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