ReactOS 0.4.15-dev-8100-g1887773
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:1880
#define SHCNE_DELETE
Definition: shlobj.h:1878
#define SHCNE_MKDIR
Definition: shlobj.h:1879
#define SHCNE_UPDATEITEM
Definition: shlobj.h:1889
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1876
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1888
#define SHCNE_CREATE
Definition: shlobj.h:1877
#define SHCNE_RENAMEFOLDER
Definition: shlobj.h:1893

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:3225
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3092
#define assert(x)
Definition: debug.h:53
#define L(x)
Definition: ntvdm.h:50
#define PathAppendW
Definition: pathcch.h:309
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:995
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2174
#define CSIDL_PERSONAL
Definition: shlobj.h:2164
#define CSIDL_PRINTERS
Definition: shlobj.h:2163
#define CSIDL_DESKTOP
Definition: shlobj.h:2159
#define CSIDL_DRIVES
Definition: shlobj.h:2175
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
int ret
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by OnCreate().

◆ DoSendData()

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

Definition at line 252 of file shell32_apitest_sub.cpp.

253{
254 DWORD cbPidl1 = ILGetSize(pidl1), cbPidl2 = ILGetSize(pidl2);
255 DWORD cbTotal = sizeof(lEvent) + sizeof(cbPidl1) + sizeof(cbPidl2) + cbPidl1 + cbPidl2;
256 LPBYTE pbData = (LPBYTE)::LocalAlloc(LPTR, cbTotal);
257 if (!pbData)
258 return FALSE;
259
260 LPBYTE pb = pbData;
261
262 *(LONG*)pb = lEvent;
263 pb += sizeof(lEvent);
264
265 *(DWORD*)pb = cbPidl1;
266 pb += sizeof(cbPidl1);
267
268 *(DWORD*)pb = cbPidl2;
269 pb += sizeof(cbPidl2);
270
271 CopyMemory(pb, pidl1, cbPidl1);
272 pb += cbPidl1;
273
274 CopyMemory(pb, pidl2, cbPidl2);
275 pb += cbPidl2;
276
277 assert(INT(pb - pbData) == INT(cbTotal));
278
279 COPYDATASTRUCT CopyData;
280 CopyData.dwData = 0xBEEFCAFE;
281 CopyData.cbData = cbTotal;
282 CopyData.lpData = pbData;
284
286 return ret;
287}
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:3001
HANDLE lEvent
Definition: tftpd.cpp:56
unsigned char * LPBYTE
Definition: typedefs.h:53
#define LPTR
Definition: winbase.h:381
#define CopyMemory
Definition: winbase.h:1710
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WM_COPYDATA
Definition: winuser.h:1664
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 289 of file shell32_apitest_sub.cpp.

290{
291 if (s_iStage < 0)
292 return;
293
294 DoSendData(lEvent, pidl1, pidl2);
295}
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
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 }
179 default:
180 {
181 assert(0);
182 break;
183 }
184 }
185
187 if (s_uRegID == 0)
188 return FALSE;
189
190 return TRUE;
191}
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
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:1923
#define SHCNRF_NewDelivery
Definition: shlobj.h:1924
#define SHCNRF_ShellLevel
Definition: shlobj.h:1922
#define SHCNRF_InterruptLevel
Definition: shlobj.h:1921
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 202 of file shell32_apitest_sub.cpp.

203{
204 switch (id)
205 {
206 case IDYES: // Start testing
207 {
209 if (!s_hMainWnd)
210 {
212 break;
213 }
214 s_iStage = 0;
215 InitSHCN(hwnd);
217 break;
218 }
219 case IDRETRY: // New stage
220 {
222 ++s_iStage;
223 InitSHCN(hwnd);
225 break;
226 }
227 case IDNO: // Quit
228 {
229 s_iStage = -1;
232 break;
233 }
234 }
235}
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:5777
#define WM_COMMAND
Definition: winuser.h:1740
#define IDNO
Definition: winuser.h:836
#define IDYES
Definition: winuser.h:835
#define IDRETRY
Definition: winuser.h:833
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 237 of file shell32_apitest_sub.cpp.

238{
240
241 for (auto& pidl : s_pidl)
242 {
243 CoTaskMemFree(pidl);
244 pidl = NULL;
245 }
246
248
250}
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 297 of file shell32_apitest_sub.cpp.

298{
299 LONG lEvent;
300 PIDLIST_ABSOLUTE *pidlAbsolute;
301 HANDLE hLock = SHChangeNotification_Lock((HANDLE)wParam, (DWORD)lParam, &pidlAbsolute, &lEvent);
302 if (hLock)
303 {
304 DoShellNotify(hwnd, pidlAbsolute[0], pidlAbsolute[1], lEvent);
306 }
307 else
308 {
309 pidlAbsolute = (PIDLIST_ABSOLUTE *)wParam;
310 DoShellNotify(hwnd, pidlAbsolute[0], pidlAbsolute[1], lParam);
311 }
312 return TRUE;
313}
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 315 of file shell32_apitest_sub.cpp.

316{
317 switch (uMsg)
318 {
319 case WM_CREATE:
320 return (OnCreate(hwnd) ? 0 : -1);
321
322 case WM_COMMAND:
324 break;
325
326 case WM_SHELL_NOTIFY:
328
329 case WM_DESTROY:
331 break;
332
333 default:
334 return ::DefWindowProcW(hwnd, uMsg, wParam, lParam);
335 }
336 return 0;
337}
#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:1608
#define WM_DESTROY
Definition: winuser.h:1609

Referenced by wWinMain().

◆ UnInitSHCN()

static void UnInitSHCN ( HWND  hwnd)
static

Definition at line 193 of file shell32_apitest_sub.cpp.

194{
195 if (s_uRegID)
196 {
198 s_uRegID = 0;
199 }
200}
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 340 of file shell32_apitest_sub.cpp.

345{
346 if (lstrcmpiW(lpCmdLine, L"") == 0 || lstrcmpiW(lpCmdLine, L"TEST") == 0)
347 return 0;
348
349 WNDCLASSW wc = { 0, SubWindowProc };
350 wc.hInstance = hInstance;
353 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
355 if (!RegisterClassW(&wc))
356 {
357 assert(0);
358 return -1;
359 }
360
362 CW_USEDEFAULT, CW_USEDEFAULT, 400, 100,
364 if (!hwnd)
365 {
366 assert(0);
367 return -2;
368 }
369
372
373 MSG msg;
374 while (GetMessageW(&msg, NULL, 0, 0))
375 {
378 }
379
380 return 0;
381}
#define msg(x)
Definition: auth_time.c:54
HINSTANCE hInstance
Definition: charmap.c:19
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4261
#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:3185
HBRUSH hbrBackground
Definition: winuser.h:3183
HICON hIcon
Definition: winuser.h:3181
HINSTANCE hInstance
Definition: winuser.h:3180
HCURSOR hCursor
Definition: winuser.h:3182
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define SW_SHOWNORMAL
Definition: winuser.h:770
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:687
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2136
#define IDI_APPLICATION
Definition: winuser.h:704
BOOL WINAPI UpdateWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4316
#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:2106
#define COLOR_3DFACE
Definition: winuser.h:929

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().