#include <windows.h>
#include <shlobj.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlstr.h>
#include <atlsimpcoll.h>
#include <conio.h>
#include <shellutils.h>
Go to the source code of this file.
|
HRESULT | CreateIDataObject (CComHeapPtr< ITEMIDLIST > &pidl, CComPtr< IDataObject > &dataObject, PCWSTR FileName) |
|
HRESULT | LoadAndInitialize (REFIID riid, LPVOID *ppv) |
|
BOOL CALLBACK | EnumWindowsProc (HWND hwnd, LPARAM lParam) |
|
void | WaitWindows () |
|
static BOOL CALLBACK | cb_AddPage (HPROPSHEETPAGE page, LPARAM lParam) |
|
static bool | isCmdWithArg (int argc, WCHAR **argv, int &n, PCWSTR check, PCWSTR &arg) |
|
static bool | isCmd (int argc, WCHAR **argv, int n, PCWSTR check) |
|
static void | PrintHelp (PCWSTR ExtraLine) |
|
int | wmain (int argc, WCHAR **argv) |
|
◆ WaitType
Enumerator |
---|
Wait_None | |
Wait_Infinite | |
Wait_OpenWindows | |
Wait_Input | |
Definition at line 17 of file shlextdbg.cpp.
◆ cb_AddPage()
Definition at line 160 of file shlextdbg.cpp.
161{
164 {
165 wprintf(
L"Propsheet failed to pass lParam, got: 0x%Ix\n",
lParam);
166 }
168}
CSimpleArray< HPROPSHEETPAGE > g_Pages
Referenced by wmain().
◆ CreateIDataObject()
Definition at line 32 of file shlextdbg.cpp.
33{
36 {
39 }
40
45 {
46 wprintf(
L"Failed to bind to parent: 0x%x\n",
hr);
48 }
51 {
52 wprintf(
L"Failed to query IDataObject: 0x%x\n",
hr);
53 }
55}
const GUID IID_IDataObject
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
#define IID_PPV_ARG(Itype, ppType)
Referenced by LoadAndInitialize().
◆ EnumWindowsProc()
Definition at line 127 of file shlextdbg.cpp.
128{
130 {
134 {
136 }
137 }
139}
CSimpleArray< HWND > g_Windows
DWORD WINAPI GetCurrentProcessId(void)
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Referenced by WaitWindows().
◆ isCmd()
◆ isCmdWithArg()
Definition at line 170 of file shlextdbg.cpp.
171{
175 {
177 if (*
cmd ==
':' || *
cmd ==
'=')
178 {
180 return true;
181 }
183 {
186 return true;
187 }
189 return false;
190 }
191 return false;
192}
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
Referenced by wmain().
◆ LoadAndInitialize()
Definition at line 57 of file shlextdbg.cpp.
58{
62 {
65 {
70 }
71 }
72 else
73 {
77 {
80 }
81 tDllGetClassObject DllGet = (tDllGetClassObject)
GetProcAddress(
mod,
"DllGetClassObject");
82 if (!DllGet)
83 {
86 }
90 {
91 wprintf(
L"Failed to create IClassFactory: 0x%x\n",
hr);
93 }
96 {
97 wprintf(
L"Failed to Request IShellExtInit from IClassFactory: 0x%x\n",
hr);
99 }
100 }
101
107
108 hr = spShellExtInit->Initialize(pidl, spDataObject,
NULL);
110 {
111 wprintf(
L"IShellExtInit->Initialize failed: 0x%x\n",
hr);
113 }
114 hr = spShellExtInit->QueryInterface(
riid,
ppv);
116 {
120 }
122}
#define GetProcAddress(x, y)
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
HRESULT CreateIDataObject(CComHeapPtr< ITEMIDLIST > &pidl, CComPtr< IDataObject > &dataObject, PCWSTR FileName)
DWORD WINAPI GetLastError(void)
Referenced by wmain().
◆ PrintHelp()
Definition at line 199 of file shlextdbg.cpp.
200{
201 if (ExtraLine)
203
204 wprintf(
L"shlextdbg /clsid={clsid} [/dll=dllname] /IShellExtInit=filename |shlextype| |waitoptions|\n");
205 wprintf(
L" {clsid}: The CLSID or ProgID of the object to create\n");
206 wprintf(
L" dll: Optional dllname to create the object from, instead of CoCreateInstance\n");
207 wprintf(
L" filename: The filename to pass to IShellExtInit->Initialze\n");
208 wprintf(
L" shlextype: The type of shell extention to run:\n");
209 wprintf(
L" /IShellPropSheetExt to create a property sheet\n");
210 wprintf(
L" /IContextMenu=verb to activate the specified verb\n");
211 wprintf(
L" waitoptions: Specify how to wait:\n");
212 wprintf(
L" /infinite: Keep on waiting infinitely\n");
213 wprintf(
L" /openwindows: Wait for all windows from the current application to close\n");
214 wprintf(
L" /input: Wait for input\n");
216}
◆ WaitWindows()
Definition at line 141 of file shlextdbg.cpp.
142{
143
146 while (true)
147 {
151 break;
153 }
154 wprintf(
L"All windows closed (ignoring console window)\n");
155}
HWND WINAPI DECLSPEC_HOTPATCH GetConsoleWindow(VOID)
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)
Referenced by wmain().
◆ wmain()
Definition at line 227 of file shlextdbg.cpp.
228{
229 bool failArgs = false;
231 {
233 if (
cmd[0] ==
'-' ||
cmd[0] ==
'/')
234 {
237 {
240 {
242 failArgs = true;
243 }
244 }
246 {
248 }
250 {
252 }
254 {
256 }
258 {
260 }
262 {
264 }
266 {
268 }
270 {
272 }
273 else
274 {
276 failArgs = true;
277 }
278 }
279 }
280
281 if (failArgs)
282 {
285 }
286
287
288 CLSID EmptyCLSID = { 0 };
290 {
293 }
294
296 {
299 }
300
304
307 {
312
315 {
316 wprintf(
L"IShellPropSheetExt->AddPages failed: 0x%x\n",
hr);
318 }
319
322
328 psh.
nStartPage = ActivePage ? (ActivePage-1) : 0;
330
331 wprintf(
L"PropertySheetW returned: 0x%x\n",
hr);
332 }
334 {
339
340 CMINVOKECOMMANDINFO cm = { sizeof(cm), 0 };
343 hr = spContextMenu->InvokeCommand(&cm);
344
346 {
347 wprintf(
L"IContextMenu->InvokeCommand failed: 0x%x\n",
hr);
349 }
350 wprintf(
L"IContextMenu->InvokeCommand returned: 0x%x\n",
hr);
351 }
352
354 {
356 break;
358 while (true) {
360 }
361 break;
364 break;
366 wprintf(
L"Press any key to continue...\n");
368 break;
369
370 }
371 return 0;
372}
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
#define ICC_STANDARD_CLASSES
static BOOL CALLBACK cb_AddPage(HPROPSHEETPAGE page, LPARAM lParam)
static bool isCmdWithArg(int argc, WCHAR **argv, int &n, PCWSTR check, PCWSTR &arg)
static bool isCmd(int argc, WCHAR **argv, int n, PCWSTR check)
HRESULT LoadAndInitialize(REFIID riid, LPVOID *ppv)
bool g_bIShellPropSheetExt
◆ g_bIShellPropSheetExt
◆ g_CLSID
◆ g_ConsoleWindow
◆ g_ContextMenu
◆ g_DLL
◆ g_Pages
◆ g_ShellExtInit
◆ g_Wait
◆ g_Windows