ReactOS 0.4.17-dev-1266-g5d5a280
shelltest.h
Go to the documentation of this file.
1#ifndef _SHELLTEST_H_
2#define _SHELLTEST_H_
3
4//#define _INC_WINDOWS
5#define COM_NO_WINDOWS_H
6
7#include <ntstatus.h>
8#define WIN32_NO_STATUS
9#include <apitest.h>
10#include <winreg.h>
11#include <shlobj.h>
12#include <shellapi.h>
13#include <shlwapi.h>
14#include <atlbase.h>
15#include <atlcom.h>
16
17// Vista's shell32 is buggy so we need to skip some tests there.
19
20HRESULT PathToIDList(LPCWSTR pszPath, ITEMIDLIST** ppidl);
21
23{
24 ITEMIDLIST *pidl = NULL;
25 HRESULT hr = PathToIDList(pszPath, &pidl);
26 return SUCCEEDED(hr) ? pidl : NULL;
27}
28
30{
31 return (s && *s) ? s : L"(Default)";
32}
33
35{
36 return SHSetValueW(hKey, Path, Name, Type, (LPCVOID)Str, (lstrlenW(Str) + 1) * sizeof(WCHAR));
37}
38
40{
42}
43
44#ifdef __cplusplus
45template<class R>
46HRESULT SHELL_BindToObject(IShellFolder *pSF, LPCITEMIDLIST pidl, IBindCtx *pBC, R riid, void **ppv)
47{
48 CComPtr<IShellFolder> psfDesktop;
49 HRESULT hr;
50 if (!pSF)
51 {
52 if (FAILED(hr = SHGetDesktopFolder(&psfDesktop)))
53 return hr;
54 pSF = psfDesktop;
55 }
56 hr = ILIsEmpty(pidl) ? pSF->QueryInterface(riid, ppv) : pSF->BindToObject(pidl, pBC, riid, ppv);
57 if (SUCCEEDED(hr) && !*ppv)
58 hr = E_FAIL;
59 return hr;
60}
61#endif
62
63#endif /* !_SHELLTEST_H_ */
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
PRTL_UNICODE_STRING_BUFFER Path
Type
Definition: Type.h:7
#define GetNTVersion()
Definition: apitest.h:17
#define REG_SZ
Definition: layer.c:22
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:582
LPWSTR Name
Definition: desk.c:124
@ R
Definition: bidi.c:79
#define NULL
Definition: types.h:112
#define lstrlenW
Definition: compat.h:750
DWORD WINAPI SHSetValueW(HKEY hkey, const WCHAR *subkey, const WCHAR *value, DWORD type, const void *data, DWORD data_len)
Definition: main.c:2292
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLdouble s
Definition: gl.h:2039
unsigned int UINT
Definition: sysinfo.c:13
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT BindToObject([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
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
CONST void * LPCVOID
Definition: minwindef.h:164
short WCHAR
Definition: pedump.c:58
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
HRESULT PathToIDList(LPCWSTR pszPath, ITEMIDLIST **ppidl)
Definition: shelltest.cpp:83
static UINT RegSetStringEx(HKEY hKey, LPCWSTR Path, LPCWSTR Name, LPCWSTR Str, DWORD Type)
Definition: shelltest.h:34
static LPCWSTR RegNameDisp(LPCWSTR s)
Definition: shelltest.h:29
static UINT RegSetString(HKEY hKey, LPCWSTR Path, LPCWSTR Name, LPCWSTR Str)
Definition: shelltest.h:39
static const BOOL g_bVista
Definition: shelltest.h:18
static LPITEMIDLIST SHELL_SimpleIDListFromPath(LPCWSTR pszPath)
Definition: shelltest.h:22
static BOOL ILIsEmpty(_In_opt_ PCUIDLIST_RELATIVE pidl)
Definition: shlobj.h:2566
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
const uint16_t * LPCWSTR
Definition: typedefs.h:57