ReactOS 0.4.16-dev-1520-gb558596
shell32_apitest_sub.cpp File Reference
#include "shelltest.h"
#include "shell32_apitest_sub.h"
#include <assert.h>
Include dependency graph for shell32_apitest_sub.cpp:

Go to the source code of this file.

Macros

#define EVENTS
 

Typedefs

typedef enum DIRTYPE DIRTYPE
 

Enumerations

enum  DIRTYPE {
  DIRTYPE_DESKTOP = 0 , DIRTYPE_DESKTOP_DIR , DIRTYPE_DRIVES , DIRTYPE_PRINTERS ,
  DIRTYPE_DIR1 , DIRTYPE_MAX
}
 

Functions

LPITEMIDLIST DoGetPidl (INT iDir)
 
static BOOL OnCreate (HWND hwnd)
 
static BOOL InitSHCN (HWND hwnd)
 
static void UnInitSHCN (HWND hwnd)
 
static void OnCommand (HWND hwnd, UINT id)
 
static void OnDestroy (HWND hwnd)
 
static BOOL DoSendData (LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
 
static void DoShellNotify (HWND hwnd, PIDLIST_ABSOLUTE pidl1, PIDLIST_ABSOLUTE pidl2, LONG lEvent)
 
static INT_PTR OnShellNotify (HWND hwnd, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK SubWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
INT APIENTRY wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT nCmdShow)
 

Variables

static HWND s_hMainWnd = NULL
 
static HWND s_hSubWnd = NULL
 
static LPITEMIDLIST s_pidl [DIRTYPE_MAX]
 
static UINT s_uRegID = 0
 
static INT s_iStage = -1
 

Macro Definition Documentation

◆ EVENTS

#define EVENTS
Value:
#define SHCNE_RMDIR
Definition: shlobj.h:1899
#define SHCNE_DELETE
Definition: shlobj.h:1897
#define SHCNE_MKDIR
Definition: shlobj.h:1898
#define SHCNE_UPDATEITEM
Definition: shlobj.h:1908
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1895
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1907
#define SHCNE_CREATE
Definition: shlobj.h:1896
#define SHCNE_RENAMEFOLDER
Definition: shlobj.h:1912

Definition at line 29 of file shell32_apitest_sub.cpp.

Typedef Documentation

◆ DIRTYPE

typedef enum DIRTYPE DIRTYPE

Enumeration Type Documentation

◆ DIRTYPE

Enumerator
DIRTYPE_DESKTOP 
DIRTYPE_DESKTOP_DIR 
DIRTYPE_DRIVES 
DIRTYPE_PRINTERS 
DIRTYPE_DIR1 
DIRTYPE_MAX 

Definition at line 14 of file shell32_apitest_sub.cpp.

Function Documentation

◆ DoGetPidl()

LPITEMIDLIST DoGetPidl ( INT  iDir)
inline

Definition at line 32 of file shell32_apitest_sub.cpp.

33{
35
36 switch (iDir)
37 {
38 case DIRTYPE_DESKTOP:
39 {
41 break;
42 }
44 {
45 WCHAR szPath1[MAX_PATH];
47 ret = ILCreateFromPathW(szPath1);
48 break;
49 }
50 case DIRTYPE_DRIVES:
51 {
53 break;
54 }
56 {
58 break;
59 }
60 case DIRTYPE_DIR1:
61 {
62 WCHAR szPath1[MAX_PATH];
63 SHGetSpecialFolderPathW(NULL, szPath1, CSIDL_PERSONAL, FALSE); // My Documents
64 PathAppendW(szPath1, L"_TESTDIR_1_");
65 ret = ILCreateFromPathW(szPath1);
66 break;
67 }
68 default:
69 {
70 assert(0);
71 break;
72 }
73 }
74
75 return ret;
76}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3384
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3219
#define assert(x)
Definition: debug.h:53
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
#define PathAppendW
Definition: pathcch.h:310
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:1102
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2194
#define CSIDL_PERSONAL
Definition: shlobj.h:2184
#define CSIDL_PRINTERS
Definition: shlobj.h:2183
#define CSIDL_DESKTOP
Definition: shlobj.h:2179
#define CSIDL_DRIVES
Definition: shlobj.h:2195
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by OnCreate().

◆ DoSendData()

static BOOL DoSendData ( LONG  lEvent,
LPCITEMIDLIST  pidl1,
LPCITEMIDLIST  pidl2 
)
static

Definition at line 248 of file shell32_apitest_sub.cpp.

249{
250 DWORD cbPidl1 = ILGetSize(pidl1), cbPidl2 = ILGetSize(pidl2);
251 DWORD cbTotal = sizeof(lEvent) + sizeof(cbPidl1) + sizeof(cbPidl2) + cbPidl1 + cbPidl2;
252 LPBYTE pbData = (LPBYTE)::LocalAlloc(LPTR, cbTotal);
253 if (!pbData)
254 return FALSE;
255
256 LPBYTE pb = pbData;
257
258 *(LONG*)pb = lEvent;
259 pb += sizeof(lEvent);
260
261 *(DWORD*)pb = cbPidl1;
262 pb += sizeof(cbPidl1);
263
264 *(DWORD*)pb = cbPidl2;
265 pb += sizeof(cbPidl2);
266
267 CopyMemory(pb, pidl1, cbPidl1);
268 pb += cbPidl1;
269
270 CopyMemory(pb, pidl2, cbPidl2);
271 pb += cbPidl2;
272
273 assert(INT(pb - pbData) == INT(cbTotal));
274
275 COPYDATASTRUCT CopyData;
276 CopyData.dwData = 0xBEEFCAFE;
277 CopyData.cbData = cbTotal;
278 CopyData.lpData = pbData;
280
281 ::LocalFree(pbData);
282 return ret;
283}
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define BOOL
Definition: nt_native.h:43
long LONG
Definition: pedump.c:60
#define INT
Definition: polytest.cpp:20
static HWND s_hSubWnd
static HWND s_hMainWnd
#define ILGetSize
Definition: shellclasses.h:638
ULONG_PTR dwData
Definition: winuser.h:3103
HANDLE lEvent
Definition: tftpd.cpp:56
unsigned char * LPBYTE
Definition: typedefs.h:53
#define LPTR
Definition: winbase.h:414
#define CopyMemory
Definition: winbase.h:1751
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WM_COPYDATA
Definition: winuser.h:1692
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by DoShellNotify().

◆ DoShellNotify()

static void DoShellNotify ( HWND  hwnd,
PIDLIST_ABSOLUTE  pidl1,
PIDLIST_ABSOLUTE  pidl2,
LONG  lEvent 
)
static

Definition at line 285 of file shell32_apitest_sub.cpp.

286{
287 if (s_iStage < 0)
288 return;
289
290 DoSendData(lEvent, pidl1, pidl2);
291}
static BOOL DoSendData(LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
static INT s_iStage

Referenced by OnShellNotify().

◆ InitSHCN()

static BOOL InitSHCN ( HWND  hwnd)
static

Definition at line 88 of file shell32_apitest_sub.cpp.

89{
90 assert(0 <= s_iStage);
92
94 INT sources = 0;
96 switch (s_iStage)
97 {
98 case 0:
99 {
100 entry.fRecursive = FALSE;
101 entry.pidl = NULL;
103 events = EVENTS;
104 break;
105 }
106 case 1:
107 {
108 entry.fRecursive = TRUE;
109 entry.pidl = NULL;
111 events = EVENTS;
112 break;
113 }
114 case 2:
115 {
116 entry.fRecursive = FALSE;
119 events = EVENTS;
120 break;
121 }
122 case 3:
123 {
124 entry.fRecursive = TRUE;
127 events = EVENTS;
128 break;
129 }
130 case 4:
131 {
132 entry.fRecursive = TRUE;
135 events = EVENTS;
136 break;
137 }
138 case 5:
139 {
140 entry.fRecursive = FALSE;
143 events = EVENTS;
144 break;
145 }
146 case 6:
147 {
148 entry.fRecursive = TRUE;
151 events = EVENTS;
152 break;
153 }
154 case 7:
155 {
156 entry.fRecursive = TRUE;
159 events = EVENTS;
160 break;
161 }
162 case 8:
163 {
164 entry.fRecursive = FALSE;
165 entry.pidl = s_pidl[DIRTYPE_DIR1];
167 events = EVENTS;
168 break;
169 }
170 case 9:
171 {
172 entry.fRecursive = TRUE;
173 entry.pidl = s_pidl[DIRTYPE_DIR1];
176 events = EVENTS;
177 break;
178 }
180 }
181
183 if (s_uRegID == 0)
184 return FALSE;
185
186 return TRUE;
187}
EXTERN_C ULONG WINAPI SHChangeNotifyRegister(HWND hwnd, INT fSources, LONG wEventMask, UINT uMsg, INT cItems, SHChangeNotifyEntry *lpItems)
#define TRUE
Definition: types.h:120
GLsizei GLenum * sources
Definition: glext.h:7753
uint32_t entry
Definition: isohybrid.c:63
HANDLE events[2]
Definition: event.c:4
#define DEFAULT_UNREACHABLE
static UINT s_uRegID
static LPITEMIDLIST s_pidl[DIRTYPE_MAX]
#define EVENTS
#define WM_SHELL_NOTIFY
#define NUM_STAGE
#define SHCNRF_RecursiveInterrupt
Definition: shlobj.h:1943
#define SHCNRF_NewDelivery
Definition: shlobj.h:1944
#define SHCNRF_ShellLevel
Definition: shlobj.h:1942
#define SHCNRF_InterruptLevel
Definition: shlobj.h:1941
int32_t INT
Definition: typedefs.h:58
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by OnCommand().

◆ OnCommand()

static void OnCommand ( HWND  hwnd,
UINT  id 
)
static

Definition at line 198 of file shell32_apitest_sub.cpp.

199{
200 switch (id)
201 {
202 case IDYES: // Start testing
203 {
205 if (!s_hMainWnd)
206 {
208 break;
209 }
210 s_iStage = 0;
211 InitSHCN(hwnd);
213 break;
214 }
215 case IDRETRY: // New stage
216 {
218 ++s_iStage;
219 InitSHCN(hwnd);
221 break;
222 }
223 case IDNO: // Quit
224 {
225 s_iStage = -1;
228 break;
229 }
230 }
231}
static void UnInitSHCN(HWND hwnd)
static BOOL InitSHCN(HWND hwnd)
#define MAIN_CLASSNAME
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define FindWindow
Definition: winuser.h:5888
#define WM_COMMAND
Definition: winuser.h:1768
#define IDNO
Definition: winuser.h:847
#define IDYES
Definition: winuser.h:846
#define IDRETRY
Definition: winuser.h:844
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by SubWindowProc().

◆ OnCreate()

static BOOL OnCreate ( HWND  hwnd)
static

Definition at line 78 of file shell32_apitest_sub.cpp.

79{
81
82 for (INT i = 0; i < DIRTYPE_MAX; ++i)
83 s_pidl[i] = DoGetPidl(i);
84
85 return TRUE;
86}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LPITEMIDLIST DoGetPidl(INT iDir)

Referenced by SubWindowProc().

◆ OnDestroy()

static void OnDestroy ( HWND  hwnd)
static

Definition at line 233 of file shell32_apitest_sub.cpp.

234{
236
237 for (auto& pidl : s_pidl)
238 {
239 CoTaskMemFree(pidl);
240 pidl = NULL;
241 }
242
244
246}
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

Referenced by SubWindowProc().

◆ OnShellNotify()

static INT_PTR OnShellNotify ( HWND  hwnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 293 of file shell32_apitest_sub.cpp.

294{
295 LONG lEvent;
296 PIDLIST_ABSOLUTE *pidlAbsolute;
297 HANDLE hLock = SHChangeNotification_Lock((HANDLE)wParam, (DWORD)lParam, &pidlAbsolute, &lEvent);
298 if (hLock)
299 {
300 DoShellNotify(hwnd, pidlAbsolute[0], pidlAbsolute[1], lEvent);
302 }
303 else
304 {
305 pidlAbsolute = (PIDLIST_ABSOLUTE *)wParam;
306 DoShellNotify(hwnd, pidlAbsolute[0], pidlAbsolute[1], lParam);
307 }
308 return TRUE;
309}
EXTERN_C HANDLE WINAPI SHChangeNotification_Lock(HANDLE hTicket, DWORD dwOwnerPID, LPITEMIDLIST **lppidls, LPLONG lpwEventId)
EXTERN_C BOOL WINAPI SHChangeNotification_Unlock(HANDLE hLock)
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static void DoShellNotify(HWND hwnd, PIDLIST_ABSOLUTE pidl1, PIDLIST_ABSOLUTE pidl2, LONG lEvent)

Referenced by SubWindowProc().

◆ SubWindowProc()

static LRESULT CALLBACK SubWindowProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 311 of file shell32_apitest_sub.cpp.

312{
313 switch (uMsg)
314 {
315 case WM_CREATE:
316 return (OnCreate(hwnd) ? 0 : -1);
317
318 case WM_COMMAND:
320 break;
321
322 case WM_SHELL_NOTIFY:
324
325 case WM_DESTROY:
327 break;
328
329 default:
330 return ::DefWindowProcW(hwnd, uMsg, wParam, lParam);
331 }
332 return 0;
333}
#define LOWORD(l)
Definition: pedump.c:82
static BOOL OnCreate(HWND hwnd)
static void OnCommand(HWND hwnd, UINT id)
static void OnDestroy(HWND hwnd)
static INT_PTR OnShellNotify(HWND hwnd, WPARAM wParam, LPARAM lParam)
#define WM_CREATE
Definition: winuser.h:1636
#define WM_DESTROY
Definition: winuser.h:1637

Referenced by wWinMain().

◆ UnInitSHCN()

static void UnInitSHCN ( HWND  hwnd)
static

Definition at line 189 of file shell32_apitest_sub.cpp.

190{
191 if (s_uRegID)
192 {
194 s_uRegID = 0;
195 }
196}
EXTERN_C BOOL WINAPI SHChangeNotifyDeregister(ULONG hNotify)

Referenced by OnCommand(), and OnDestroy().

◆ wWinMain()

INT APIENTRY wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
INT  nCmdShow 
)

Definition at line 336 of file shell32_apitest_sub.cpp.

341{
342 if (lstrcmpiW(lpCmdLine, L"") == 0 || lstrcmpiW(lpCmdLine, L"TEST") == 0)
343 return 0;
344
345 WNDCLASSW wc = { 0, SubWindowProc };
346 wc.hInstance = hInstance;
349 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
351 if (!RegisterClassW(&wc))
352 {
353 assert(0);
354 return -1;
355 }
356
358 CW_USEDEFAULT, CW_USEDEFAULT, 400, 100,
360 if (!hwnd)
361 {
362 assert(0);
363 return -2;
364 }
365
368
369 MSG msg;
370 while (GetMessageW(&msg, NULL, 0, 0))
371 {
374 }
375
376 return 0;
377}
#define msg(x)
Definition: auth_time.c:54
HINSTANCE hInstance
Definition: charmap.c:19
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4265
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
static LRESULT CALLBACK SubWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define SUB_CLASSNAME
LPCWSTR lpszClassName
Definition: winuser.h:3287
HBRUSH hbrBackground
Definition: winuser.h:3285
HICON hIcon
Definition: winuser.h:3283
HINSTANCE hInstance
Definition: winuser.h:3282
HCURSOR hCursor
Definition: winuser.h:3284
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define SW_SHOWNORMAL
Definition: winuser.h:781
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:695
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2457
#define IDI_APPLICATION
Definition: winuser.h:712
BOOL WINAPI UpdateWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4418
#define CW_USEDEFAULT
Definition: winuser.h:225
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2427
#define COLOR_3DFACE
Definition: winuser.h:940

Variable Documentation

◆ s_hMainWnd

HWND s_hMainWnd = NULL
static

Definition at line 24 of file shell32_apitest_sub.cpp.

Referenced by DoSendData(), OnCommand(), and OnDestroy().

◆ s_hSubWnd

HWND s_hSubWnd = NULL
static

Definition at line 24 of file shell32_apitest_sub.cpp.

Referenced by DoSendData(), and OnCreate().

◆ s_iStage

INT s_iStage = -1
static

Definition at line 27 of file shell32_apitest_sub.cpp.

Referenced by DoShellNotify(), InitSHCN(), and OnCommand().

◆ s_pidl

LPITEMIDLIST s_pidl[DIRTYPE_MAX]
static

Definition at line 25 of file shell32_apitest_sub.cpp.

Referenced by InitSHCN(), OnCreate(), and OnDestroy().

◆ s_uRegID

UINT s_uRegID = 0
static

Definition at line 26 of file shell32_apitest_sub.cpp.

Referenced by InitSHCN(), and UnInitSHCN().