1 #pragma once
2
3 #include <shlwapi.h>
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <strsafe.h>
7
8 #define MAIN_CLASSNAME L"SHChangeNotify main window"
9 #define SUB_CLASSNAME L"SHChangeNotify sub-window"
10
11 #define WM_SHELL_NOTIFY (WM_USER + 100)
12
13 #define NUM_STAGE 10
14
FindSubProgram(LPWSTR pszSubProgram,DWORD cchSubProgram)15 static inline BOOL FindSubProgram(LPWSTR pszSubProgram, DWORD cchSubProgram)
16 {
17 GetModuleFileNameW(NULL, pszSubProgram, cchSubProgram);
18 PathRemoveFileSpecW(pszSubProgram);
19 PathAppendW(pszSubProgram, L"shell32_apitest_sub.exe");
20
21 if (!PathFileExistsW(pszSubProgram))
22 {
23 PathRemoveFileSpecW(pszSubProgram);
24 PathAppendW(pszSubProgram, L"testdata\\shell32_apitest_sub.exe");
25
26 if (!PathFileExistsW(pszSubProgram))
27 return FALSE;
28 }
29
30 return TRUE;
31 }
32
DoWaitForWindow(LPCWSTR clsname,LPCWSTR text,BOOL bClosing,BOOL bForce)33 static inline HWND DoWaitForWindow(LPCWSTR clsname, LPCWSTR text, BOOL bClosing, BOOL bForce)
34 {
35 HWND hwnd = NULL;
36 for (INT i = 0; i < 50; ++i)
37 {
38 hwnd = FindWindowW(clsname, text);
39 if (bClosing)
40 {
41 if (!hwnd)
42 break;
43
44 if (bForce)
45 PostMessage(hwnd, WM_CLOSE, 0, 0);
46 }
47 else
48 {
49 if (hwnd)
50 break;
51 }
52
53 Sleep(1);
54 }
55 return hwnd;
56 }
57