Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158/* * PROJECT: ReactOS api tests * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) * PURPOSE: Tests for shdocvw!WinList_* functions * COPYRIGHT: Copyright 2025 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> */
#include <apitest.h>#include <shlobj.h>
typedef BOOL (WINAPI *FN_WinList_Init)(VOID);typedef VOID (WINAPI *FN_WinList_Terminate)(VOID);typedef IShellWindows* (WINAPI *FN_WinList_GetShellWindows)(BOOL);
static FN_WinList_Init g_pWinList_Init = NULL;static FN_WinList_Terminate g_pWinList_Terminate = NULL;static FN_WinList_GetShellWindows g_pWinList_GetShellWindows = NULL;
static VOIDTEST_WinList_GetShellWindows(VOID){ BOOL bInited = g_pWinList_Init && g_pWinList_Init(); ok_int(bInited, FALSE); // WinList_Init should fail because this process is not explorer.exe
IShellWindows *pShellWindows1 = g_pWinList_GetShellWindows(FALSE); trace("%p\n", pShellWindows1); ok(pShellWindows1 != NULL, "pShellWindows1 was null\n");
IShellWindows *pShellWindows2 = g_pWinList_GetShellWindows(FALSE); trace("%p\n", pShellWindows2); ok(pShellWindows2 != NULL, "pShellWindows2 was null\n");
IShellWindows *pShellWindows3 = g_pWinList_GetShellWindows(TRUE); trace("%p\n", pShellWindows3); ok(pShellWindows3 != NULL, "pShellWindows3 was null\n");
ok_ptr(pShellWindows1, pShellWindows2); ok_ptr(pShellWindows2, pShellWindows3);
if (pShellWindows1) { LONG nCount = -1; HRESULT hr = pShellWindows1->get_Count(&nCount); ok_hex(hr, S_OK); ok(nCount >= 0, "nCount was %ld\n", nCount); trace("%ld\n", nCount);
pShellWindows1->Release(); } else { ok_int(TRUE, FALSE); ok_int(TRUE, FALSE); }
if (pShellWindows2) pShellWindows2->Release();
if (pShellWindows3) pShellWindows3->Release();
if (bInited && g_pWinList_Terminate) g_pWinList_Terminate();}
static VOIDTEST_WinList_Mix(VOID){ IShellWindows *pShellWindows1 = g_pWinList_GetShellWindows(FALSE); trace("%p\n", pShellWindows1); ok(pShellWindows1 != NULL, "pShellWindows1 was null\n");
IShellWindows *pShellWindows2 = NULL; CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IShellWindows, (LPVOID *)&pShellWindows2); ok(pShellWindows2 != NULL, "pShellWindows2 was null\n");
ok_ptr(pShellWindows1, pShellWindows2);
if (pShellWindows1) pShellWindows1->Release(); if (pShellWindows2) pShellWindows2->Release();}
static VOIDTEST_SHDOCVW_WinList(VOID){ HINSTANCE hSHDOCVW = LoadLibraryW(L"shdocvw.dll"); if (!hSHDOCVW) { skip("shdocvw.dll not loaded\n"); return; }
g_pWinList_Init = (FN_WinList_Init)GetProcAddress(hSHDOCVW, MAKEINTRESOURCEA(110)); g_pWinList_Terminate = (FN_WinList_Terminate)GetProcAddress(hSHDOCVW, MAKEINTRESOURCEA(111)); g_pWinList_GetShellWindows = (FN_WinList_GetShellWindows)GetProcAddress(hSHDOCVW, MAKEINTRESOURCEA(179)); if (!g_pWinList_Init || !g_pWinList_Terminate || !g_pWinList_GetShellWindows) { skip("Some WinList_* functions not found: %p %p %p\n", g_pWinList_Init, g_pWinList_Terminate, g_pWinList_GetShellWindows); } else { TEST_WinList_GetShellWindows(); TEST_WinList_Mix(); }
FreeLibrary(hSHDOCVW);}
static VOIDTEST_CLSID_ShellWindows(VOID){ IShellWindows *pShellWindows1 = NULL; CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IShellWindows, (LPVOID *)&pShellWindows1); ok(pShellWindows1 != NULL, "pShellWindows1 was null\n");
IShellWindows *pShellWindows2 = NULL; CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IShellWindows, (LPVOID *)&pShellWindows2); ok(pShellWindows2 != NULL, "pShellWindows2 was null\n");
ok_ptr(pShellWindows1, pShellWindows2);
if (pShellWindows1) { LONG nCount = -1; HRESULT hr = pShellWindows1->get_Count(&nCount); ok_hex(hr, S_OK); ok(nCount >= 0, "nCount was %ld\n", nCount); trace("%ld\n", nCount);
pShellWindows1->Release(); } else { ok_int(TRUE, FALSE); ok_int(TRUE, FALSE); }
if (pShellWindows2) pShellWindows2->Release();}
START_TEST(WinList){ HRESULT hrCoInit = CoInitialize(NULL);
TEST_SHDOCVW_WinList(); TEST_CLSID_ShellWindows();
if (SUCCEEDED(hrCoInit)) CoUninitialize();}