Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/devenum/tests/devenum.c | 283 +++++++++++++++-------------------- 1 file changed, 120 insertions(+), 163 deletions(-)
diff --git a/dlls/devenum/tests/devenum.c b/dlls/devenum/tests/devenum.c index 726f2bf2cd8..a666b2753b6 100644 --- a/dlls/devenum/tests/devenum.c +++ b/dlls/devenum/tests/devenum.c @@ -37,15 +37,6 @@
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
-static const WCHAR friendly_name[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0}; -static const WCHAR deviceW[] = {'@','d','e','v','i','c','e',':',0}; -static const WCHAR clsidW[] = {'C','L','S','I','D',0}; -static const WCHAR waveW[] = {'w','a','v','e',':',0}; -static const WCHAR dmoW[] = {'d','m','o',':',0}; -static const WCHAR swW[] = {'s','w',':',0}; -static const WCHAR cmW[] = {'c','m',':',0}; -static const WCHAR backslashW[] = {'\',0}; - static void test_devenum(IBindCtx *bind_ctx) { IEnumMoniker *enum_cat, *enum_moniker; @@ -71,14 +62,14 @@ static void test_devenum(IBindCtx *bind_ctx) ok(hr == S_OK, "IMoniker_BindToStorage failed: %#x\n", hr);
VariantInit(&var); - hr = IPropertyBag_Read(prop_bag, clsidW, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL); ok(hr == S_OK, "Failed to read CLSID: %#x\n", hr);
hr = CLSIDFromString(V_BSTR(&var), &cat_guid); ok(hr == S_OK, "got %#x\n", hr);
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok(hr == S_OK, "Failed to read FriendlyName: %#x\n", hr);
if (winetest_debug > 1) @@ -112,7 +103,7 @@ static void test_devenum(IBindCtx *bind_ctx) hr = IMoniker_BindToStorage(moniker, bind_ctx, NULL, &IID_IPropertyBag, (LPVOID*)&prop_bag); ok(hr == S_OK, "IMoniker_BindToStorage failed with error %x\n", hr);
- hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok((hr == S_OK) | (hr == ERROR_KEY_DOES_NOT_EXIST), "IPropertyBag_Read failed: %#x\n", hr);
@@ -253,7 +244,6 @@ DEFINE_GUID(CLSID_TestFilter, 0xdeadbeef,0xcf51,0x43e6,0xb6,0xc5,0x29,0x9e,0xa8
static void test_register_filter(void) { - static const WCHAR name[] = {'d','e','v','e','n','u','m',' ','t','e','s','t',0}; IFilterMapper2 *mapper2; IMoniker *mon = NULL; REGFILTER2 rgf2 = {0}; @@ -266,7 +256,7 @@ static void test_register_filter(void) rgf2.dwMerit = MERIT_UNLIKELY; S2(U(rgf2)).cPins2 = 0;
- hr = IFilterMapper2_RegisterFilter(mapper2, &CLSID_TestFilter, name, &mon, NULL, NULL, &rgf2); + hr = IFilterMapper2_RegisterFilter(mapper2, &CLSID_TestFilter, L"devenum test", &mon, NULL, NULL, &rgf2); if (hr == E_ACCESSDENIED) { skip("Not enough permissions to register filters\n"); @@ -284,7 +274,7 @@ static void test_register_filter(void) IMoniker_Release(mon);
mon = NULL; - hr = IFilterMapper2_RegisterFilter(mapper2, &CLSID_TestFilter, name, &mon, &CLSID_AudioRendererCategory, NULL, &rgf2); + hr = IFilterMapper2_RegisterFilter(mapper2, &CLSID_TestFilter, L"devenum test", &mon, &CLSID_AudioRendererCategory, NULL, &rgf2); ok(hr == S_OK, "RegisterFilter failed: %#x\n", hr);
ok(find_moniker(&CLSID_AudioRendererCategory, mon), "filter should be registered\n"); @@ -310,7 +300,7 @@ static IMoniker *check_display_name_(int line, IParseDisplayName *parser, WCHAR
hr = IMoniker_GetDisplayName(mon, NULL, NULL, &str); ok_(__FILE__, line)(hr == S_OK, "GetDisplayName failed: %#x\n", hr); - ok_(__FILE__, line)(!lstrcmpW(str, buffer), "got %s\n", wine_dbgstr_w(str)); + ok_(__FILE__, line)(!wcscmp(str, buffer), "got %s\n", wine_dbgstr_w(str));
CoTaskMemFree(str);
@@ -320,9 +310,6 @@ static IMoniker *check_display_name_(int line, IParseDisplayName *parser, WCHAR
static void test_directshow_filter(void) { - static const WCHAR instanceW[] = {'\','I','n','s','t','a','n','c','e',0}; - static const WCHAR clsidW[] = {'C','L','S','I','D','\',0}; - static WCHAR testW[] = {'\','t','e','s','t',0}; IParseDisplayName *parser; IPropertyBag *prop_bag; IMoniker *mon; @@ -335,10 +322,9 @@ static void test_directshow_filter(void) hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser); ok(hr == S_OK, "Failed to create ParseDisplayName: %#x\n", hr);
- lstrcpyW(buffer, deviceW); - lstrcatW(buffer, swW); - StringFromGUID2(&CLSID_AudioRendererCategory, buffer + lstrlenW(buffer), CHARS_IN_GUID); - lstrcatW(buffer, testW); + wcscpy(buffer, L"@device:sw:"); + StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID); + wcscat(buffer, L"\test"); mon = check_display_name(parser, buffer);
/* Test writing and reading from the property bag */ @@ -348,13 +334,13 @@ static void test_directshow_filter(void) ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
VariantInit(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got %#x\n", hr);
/* writing causes the key to be created */ V_VT(&var) = VT_BSTR; - V_BSTR(&var) = SysAllocString(testW); - hr = IPropertyBag_Write(prop_bag, friendly_name, &var); + V_BSTR(&var) = SysAllocString(L"test"); + hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var); if (hr != E_ACCESSDENIED) { ok(hr == S_OK, "Write failed: %#x\n", hr); @@ -362,17 +348,16 @@ static void test_directshow_filter(void) ok(find_moniker(&CLSID_AudioRendererCategory, mon), "filter should be registered\n");
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr); - ok(!lstrcmpW(V_BSTR(&var), testW), "got %s\n", wine_dbgstr_w(V_BSTR(&var))); + ok(!wcscmp(V_BSTR(&var), L"test"), "got %s\n", wine_dbgstr_w(V_BSTR(&var)));
IMoniker_Release(mon);
/* devenum doesn't give us a way to unregister—we have to do that manually */ - lstrcpyW(buffer, clsidW); - StringFromGUID2(&CLSID_AudioRendererCategory, buffer + lstrlenW(buffer), CHARS_IN_GUID); - lstrcatW(buffer, instanceW); - lstrcatW(buffer, testW); + wcscpy(buffer, L"CLSID\"); + StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID); + wcscat(buffer, L"\Instance\test"); res = RegDeleteKeyW(HKEY_CLASSES_ROOT, buffer); ok(!res, "RegDeleteKey failed: %lu\n", res); } @@ -382,29 +367,27 @@ static void test_directshow_filter(void)
/* name can be anything */
- lstrcpyW(buffer, deviceW); - lstrcatW(buffer, swW); - lstrcatW(buffer, testW+1); + wcscpy(buffer, L"@device:sw:test"); mon = check_display_name(parser, buffer);
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag); ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got %#x\n", hr);
V_VT(&var) = VT_BSTR; - V_BSTR(&var) = SysAllocString(testW); - hr = IPropertyBag_Write(prop_bag, friendly_name, &var); + V_BSTR(&var) = SysAllocString(L"test"); + hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var); if (hr != E_ACCESSDENIED) { ok(hr == S_OK, "Write failed: %#x\n", hr);
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr); - ok(!lstrcmpW(V_BSTR(&var), testW), "got %s\n", wine_dbgstr_w(V_BSTR(&var))); + ok(!wcscmp(V_BSTR(&var), L"test"), "got %s\n", wine_dbgstr_w(V_BSTR(&var)));
IMoniker_Release(mon);
@@ -422,7 +405,6 @@ static void test_directshow_filter(void)
static void test_codec(void) { - static WCHAR testW[] = {'\','t','e','s','t',0}; IParseDisplayName *parser; IPropertyBag *prop_bag; IMoniker *mon; @@ -434,10 +416,9 @@ static void test_codec(void) hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser); ok(hr == S_OK, "Failed to create ParseDisplayName: %#x\n", hr);
- lstrcpyW(buffer, deviceW); - lstrcatW(buffer, cmW); - StringFromGUID2(&CLSID_AudioRendererCategory, buffer + lstrlenW(buffer), CHARS_IN_GUID); - lstrcatW(buffer, testW); + wcscpy(buffer, L"@device:cm:"); + StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID); + wcscat(buffer, L"\test"); mon = check_display_name(parser, buffer);
/* Test writing and reading from the property bag */ @@ -447,25 +428,25 @@ static void test_codec(void) ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
VariantInit(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got %#x\n", hr);
V_VT(&var) = VT_BSTR; - V_BSTR(&var) = SysAllocString(testW); - hr = IPropertyBag_Write(prop_bag, friendly_name, &var); + V_BSTR(&var) = SysAllocString(L"test"); + hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var); ok(hr == S_OK, "Write failed: %#x\n", hr);
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr); - ok(!lstrcmpW(V_BSTR(&var), testW), "got %s\n", wine_dbgstr_w(V_BSTR(&var))); + ok(!wcscmp(V_BSTR(&var), L"test"), "got %s\n", wine_dbgstr_w(V_BSTR(&var)));
/* unlike DirectShow filters, these are automatically generated, so * enumerating them will destroy the key */ ok(!find_moniker(&CLSID_AudioRendererCategory, mon), "codec should not be registered\n");
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got %#x\n", hr);
IPropertyBag_Release(prop_bag); @@ -476,7 +457,6 @@ static void test_codec(void)
static void test_dmo(void) { - static const WCHAR name[] = {'d','e','v','e','n','u','m',' ','t','e','s','t',0}; IParseDisplayName *parser; IPropertyBag *prop_bag; WCHAR buffer[200]; @@ -487,10 +467,9 @@ static void test_dmo(void) hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser); ok(hr == S_OK, "Failed to create ParseDisplayName: %#x\n", hr);
- lstrcpyW(buffer, deviceW); - lstrcatW(buffer, dmoW); - StringFromGUID2(&CLSID_TestFilter, buffer + lstrlenW(buffer), CHARS_IN_GUID); - StringFromGUID2(&CLSID_AudioRendererCategory, buffer + lstrlenW(buffer), CHARS_IN_GUID); + wcscpy(buffer, L"@device:dmo:"); + StringFromGUID2(&CLSID_TestFilter, buffer + wcslen(buffer), CHARS_IN_GUID); + StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID); mon = check_display_name(parser, buffer);
ok(!find_moniker(&CLSID_AudioRendererCategory, mon), "DMO should not be registered\n"); @@ -499,15 +478,15 @@ static void test_dmo(void) ok(hr == S_OK, "got %#x\n", hr);
VariantInit(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok(hr == E_FAIL, "got %#x\n", hr);
V_VT(&var) = VT_BSTR; - V_BSTR(&var) = SysAllocString(name); - hr = IPropertyBag_Write(prop_bag, friendly_name, &var); + V_BSTR(&var) = SysAllocString(L"devenum test"); + hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var); ok(hr == E_ACCESSDENIED, "Write failed: %#x\n", hr);
- hr = DMORegister(name, &CLSID_TestFilter, &CLSID_AudioRendererCategory, 0, 0, NULL, 0, NULL); + hr = DMORegister(L"devenum test", &CLSID_TestFilter, &CLSID_AudioRendererCategory, 0, 0, NULL, 0, NULL); if (hr != E_FAIL) { ok(hr == S_OK, "got %#x\n", hr); @@ -515,18 +494,18 @@ static void test_dmo(void) ok(find_moniker(&CLSID_AudioRendererCategory, mon), "DMO should be registered\n");
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok(hr == S_OK, "got %#x\n", hr); - ok(!lstrcmpW(V_BSTR(&var), name), "got %s\n", wine_dbgstr_w(V_BSTR(&var))); + ok(!wcscmp(V_BSTR(&var), L"devenum test"), "got %s\n", wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); V_VT(&var) = VT_BSTR; - V_BSTR(&var) = SysAllocString(name); - hr = IPropertyBag_Write(prop_bag, friendly_name, &var); + V_BSTR(&var) = SysAllocString(L"devenum test"); + hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var); ok(hr == E_ACCESSDENIED, "Write failed: %#x\n", hr);
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, clsidW, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL); ok(hr == HRESULT_FROM_WIN32(ERROR_NOT_FOUND), "got %#x\n", hr);
hr = DMOUnregister(&CLSID_TestFilter, &CLSID_AudioRendererCategory); @@ -539,7 +518,6 @@ static void test_dmo(void)
static void test_legacy_filter(void) { - static const WCHAR nameW[] = {'t','e','s','t',0}; IParseDisplayName *parser; IPropertyBag *prop_bag; IFilterMapper *mapper; @@ -554,7 +532,7 @@ static void test_legacy_filter(void) hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC, &IID_IFilterMapper, (void **)&mapper); ok(hr == S_OK, "Failed to create FilterMapper: %#x\n", hr);
- hr = IFilterMapper_RegisterFilter(mapper, CLSID_TestFilter, nameW, 0xdeadbeef); + hr = IFilterMapper_RegisterFilter(mapper, CLSID_TestFilter, L"test", 0xdeadbeef); if (hr == VFW_E_BAD_KEY) { win_skip("not enough permissions to register filters\n"); @@ -562,11 +540,10 @@ static void test_legacy_filter(void) } ok(hr == S_OK, "RegisterFilter failed: %#x\n", hr);
- lstrcpyW(buffer, deviceW); - lstrcatW(buffer, cmW); - StringFromGUID2(&CLSID_LegacyAmFilterCategory, buffer + lstrlenW(buffer), CHARS_IN_GUID); - lstrcatW(buffer, backslashW); - StringFromGUID2(&CLSID_TestFilter, buffer + lstrlenW(buffer), CHARS_IN_GUID); + wcscpy(buffer, L"@device:cm:"); + StringFromGUID2(&CLSID_LegacyAmFilterCategory, buffer + wcslen(buffer), CHARS_IN_GUID); + wcscat(buffer, L"\"); + StringFromGUID2(&CLSID_TestFilter, buffer + wcslen(buffer), CHARS_IN_GUID);
mon = check_display_name(parser, buffer); ok(find_moniker(&CLSID_LegacyAmFilterCategory, mon), "filter should be registered\n"); @@ -575,17 +552,17 @@ static void test_legacy_filter(void) ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
VariantInit(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr);
StringFromGUID2(&CLSID_TestFilter, buffer, CHARS_IN_GUID); - ok(!lstrcmpW(buffer, V_BSTR(&var)), "expected %s, got %s\n", + ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n", wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, clsidW, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr); - ok(!lstrcmpW(buffer, V_BSTR(&var)), "expected %s, got %s\n", + ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n", wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); @@ -604,9 +581,6 @@ end:
static BOOL CALLBACK test_dsound(GUID *guid, const WCHAR *desc, const WCHAR *module, void *context) { - static const WCHAR defaultW[] = {'D','e','f','a','u','l','t',' ','D','i','r','e','c','t','S','o','u','n','d',' ','D','e','v','i','c','e',0}; - static const WCHAR directsoundW[] = {'D','i','r','e','c','t','S','o','u','n','d',':',' ',0}; - static const WCHAR dsguidW[] = {'D','S','G','u','i','d',0}; IParseDisplayName *parser; IPropertyBag *prop_bag; IMoniker *mon; @@ -617,23 +591,22 @@ static BOOL CALLBACK test_dsound(GUID *guid, const WCHAR *desc, const WCHAR *mod
if (guid) { - lstrcpyW(name, directsoundW); - lstrcatW(name, desc); + wcscpy(name, L"DirectSound: "); + wcscat(name, desc); } else { - lstrcpyW(name, defaultW); + wcscpy(name, L"Default DirectSound Device"); guid = (GUID *)&GUID_NULL; }
hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser); ok(hr == S_OK, "Failed to create ParseDisplayName: %#x\n", hr);
- lstrcpyW(buffer, deviceW); - lstrcatW(buffer, cmW); - StringFromGUID2(&CLSID_AudioRendererCategory, buffer + lstrlenW(buffer), CHARS_IN_GUID); - lstrcatW(buffer, backslashW); - lstrcatW(buffer, name); + wcscpy(buffer, L"@device:cm:"); + StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID); + wcscat(buffer, L"\"); + wcscat(buffer, name);
mon = check_display_name(parser, buffer);
@@ -641,19 +614,17 @@ static BOOL CALLBACK test_dsound(GUID *guid, const WCHAR *desc, const WCHAR *mod ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
VariantInit(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) { /* Win8+ uses the GUID instead of the device name */ IPropertyBag_Release(prop_bag); IMoniker_Release(mon);
- lstrcpyW(buffer, deviceW); - lstrcatW(buffer, cmW); - StringFromGUID2(&CLSID_AudioRendererCategory, buffer + lstrlenW(buffer), CHARS_IN_GUID); - lstrcatW(buffer, backslashW); - lstrcatW(buffer, directsoundW); - StringFromGUID2(guid, buffer + lstrlenW(buffer) - 1, CHARS_IN_GUID); + wcscpy(buffer, L"@device:cm:"); + StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID); + wcscat(buffer, L"\DirectSound: "); + StringFromGUID2(guid, buffer + wcslen(buffer) - 1, CHARS_IN_GUID);
mon = check_display_name(parser, buffer);
@@ -661,27 +632,27 @@ static BOOL CALLBACK test_dsound(GUID *guid, const WCHAR *desc, const WCHAR *mod ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
VariantInit(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); } ok(hr == S_OK, "Read failed: %#x\n", hr);
- ok(!lstrcmpW(name, V_BSTR(&var)), "expected %s, got %s\n", + ok(!wcscmp(name, V_BSTR(&var)), "expected %s, got %s\n", wine_dbgstr_w(name), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, clsidW, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr);
StringFromGUID2(&CLSID_DSoundRender, buffer, CHARS_IN_GUID); - ok(!lstrcmpW(buffer, V_BSTR(&var)), "expected %s, got %s\n", + ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n", wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, dsguidW, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"DSGuid", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr);
StringFromGUID2(guid, buffer, CHARS_IN_GUID); - ok(!lstrcmpW(buffer, V_BSTR(&var)), "expected %s, got %s\n", + ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n", wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); @@ -693,8 +664,6 @@ static BOOL CALLBACK test_dsound(GUID *guid, const WCHAR *desc, const WCHAR *mod
static void test_waveout(void) { - static const WCHAR defaultW[] = {'D','e','f','a','u','l','t',' ','W','a','v','e','O','u','t',' ','D','e','v','i','c','e',0}; - static const WCHAR waveoutidW[] = {'W','a','v','e','O','u','t','I','d',0}; IParseDisplayName *parser; IPropertyBag *prop_bag; IMoniker *mon; @@ -717,15 +686,14 @@ static void test_waveout(void) waveOutGetDevCapsW(i, &caps, sizeof(caps));
if (i == -1) /* WAVE_MAPPER */ - name = defaultW; + name = L"Default WaveOut Device"; else name = caps.szPname;
- lstrcpyW(buffer, deviceW); - lstrcatW(buffer, cmW); - StringFromGUID2(&CLSID_AudioRendererCategory, buffer + lstrlenW(buffer), CHARS_IN_GUID); - lstrcatW(buffer, backslashW); - lstrcatW(buffer, name); + wcscpy(buffer, L"@device:cm:"); + StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID); + wcscat(buffer, L"\"); + wcscat(buffer, name);
mon = check_display_name(parser, buffer);
@@ -733,7 +701,7 @@ static void test_waveout(void) ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
VariantInit(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) { IPropertyBag_Release(prop_bag); @@ -744,35 +712,33 @@ static void test_waveout(void) (DWORD_PTR) endpoint, sizeof(endpoint)); ok(!mmr, "waveOutMessage failed: %u\n", mmr);
- lstrcpyW(buffer, deviceW); - lstrcatW(buffer, cmW); - StringFromGUID2(&CLSID_AudioRendererCategory, buffer + lstrlenW(buffer), CHARS_IN_GUID); - lstrcatW(buffer, backslashW); - lstrcatW(buffer, waveW); - lstrcatW(buffer, wcschr(endpoint, '}') + 2); + wcscpy(buffer, L"@device:cm:"); + StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID); + wcscat(buffer, L"\wave:"); + wcscat(buffer, wcschr(endpoint, '}') + 2);
mon = check_display_name(parser, buffer);
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag); ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
- hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); } ok(hr == S_OK, "Read failed: %#x\n", hr);
- ok(!wcsncmp(name, V_BSTR(&var), lstrlenW(name)), "expected %s, got %s\n", + ok(!wcsncmp(name, V_BSTR(&var), wcslen(name)), "expected %s, got %s\n", wine_dbgstr_w(name), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, clsidW, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr);
StringFromGUID2(&CLSID_AudioRender, buffer, CHARS_IN_GUID); - ok(!lstrcmpW(buffer, V_BSTR(&var)), "expected %s, got %s\n", + ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n", wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, waveoutidW, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"WaveOutId", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr);
ok(V_I4(&var) == i, "expected %d, got %d\n", i, V_I4(&var)); @@ -786,7 +752,6 @@ static void test_waveout(void)
static void test_wavein(void) { - static const WCHAR waveinidW[] = {'W','a','v','e','I','n','I','d',0}; IParseDisplayName *parser; IPropertyBag *prop_bag; IMoniker *mon; @@ -807,11 +772,10 @@ static void test_wavein(void) { waveInGetDevCapsW(i, &caps, sizeof(caps));
- lstrcpyW(buffer, deviceW); - lstrcatW(buffer, cmW); - StringFromGUID2(&CLSID_AudioInputDeviceCategory, buffer + lstrlenW(buffer), CHARS_IN_GUID); - lstrcatW(buffer, backslashW); - lstrcatW(buffer, caps.szPname); + wcscpy(buffer, L"@device:cm:"); + StringFromGUID2(&CLSID_AudioInputDeviceCategory, buffer + wcslen(buffer), CHARS_IN_GUID); + wcscat(buffer, L"\"); + wcscat(buffer, caps.szPname);
mon = check_display_name(parser, buffer);
@@ -819,7 +783,7 @@ static void test_wavein(void) ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
VariantInit(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) { IPropertyBag_Release(prop_bag); @@ -830,35 +794,33 @@ static void test_wavein(void) (DWORD_PTR) endpoint, sizeof(endpoint)); ok(!mmr, "waveInMessage failed: %u\n", mmr);
- lstrcpyW(buffer, deviceW); - lstrcatW(buffer, cmW); - StringFromGUID2(&CLSID_AudioInputDeviceCategory, buffer + lstrlenW(buffer), CHARS_IN_GUID); - lstrcatW(buffer, backslashW); - lstrcatW(buffer, waveW); - lstrcatW(buffer, wcschr(endpoint, '}') + 2); + wcscpy(buffer, L"@device:cm:"); + StringFromGUID2(&CLSID_AudioInputDeviceCategory, buffer + wcslen(buffer), CHARS_IN_GUID); + wcscat(buffer, L"\wave:"); + wcscat(buffer, wcschr(endpoint, '}') + 2);
mon = check_display_name(parser, buffer);
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag); ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
- hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); } ok(hr == S_OK, "Read failed: %#x\n", hr);
- ok(!wcsncmp(caps.szPname, V_BSTR(&var), lstrlenW(caps.szPname)), "expected %s, got %s\n", + ok(!wcsncmp(caps.szPname, V_BSTR(&var), wcslen(caps.szPname)), "expected %s, got %s\n", wine_dbgstr_w(caps.szPname), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, clsidW, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr);
StringFromGUID2(&CLSID_AudioRecord, buffer, CHARS_IN_GUID); - ok(!lstrcmpW(buffer, V_BSTR(&var)), "expected %s, got %s\n", + ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n", wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, waveinidW, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"WaveInId", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr);
ok(V_I4(&var) == i, "expected %d, got %d\n", i, V_I4(&var)); @@ -872,8 +834,6 @@ static void test_wavein(void)
static void test_midiout(void) { - static const WCHAR defaultW[] = {'D','e','f','a','u','l','t',' ','M','i','d','i','O','u','t',' ','D','e','v','i','c','e',0}; - static const WCHAR midioutidW[] = {'M','i','d','i','O','u','t','I','d',0}; IParseDisplayName *parser; IPropertyBag *prop_bag; IMoniker *mon; @@ -894,15 +854,14 @@ static void test_midiout(void) midiOutGetDevCapsW(i, &caps, sizeof(caps));
if (i == -1) /* MIDI_MAPPER */ - name = defaultW; + name = L"Default MidiOut Device"; else name = caps.szPname;
- lstrcpyW(buffer, deviceW); - lstrcatW(buffer, cmW); - StringFromGUID2(&CLSID_MidiRendererCategory, buffer + lstrlenW(buffer), CHARS_IN_GUID); - lstrcatW(buffer, backslashW); - lstrcatW(buffer, name); + wcscpy(buffer, L"@device:cm:"); + StringFromGUID2(&CLSID_MidiRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID); + wcscat(buffer, L"\"); + wcscat(buffer, name);
mon = check_display_name(parser, buffer);
@@ -910,22 +869,22 @@ static void test_midiout(void) ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
VariantInit(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr);
- ok(!lstrcmpW(name, V_BSTR(&var)), "expected %s, got %s\n", + ok(!wcscmp(name, V_BSTR(&var)), "expected %s, got %s\n", wine_dbgstr_w(name), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, clsidW, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr);
StringFromGUID2(&CLSID_AVIMIDIRender, buffer, CHARS_IN_GUID); - ok(!lstrcmpW(buffer, V_BSTR(&var)), "expected %s, got %s\n", + ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n", wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, midioutidW, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"MidiOutId", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr);
ok(V_I4(&var) == i, "expected %d, got %d\n", i, V_I4(&var)); @@ -939,7 +898,6 @@ static void test_midiout(void)
static void test_vfw(void) { - static const WCHAR fcchandlerW[] = {'F','c','c','H','a','n','d','l','e','r',0}; IParseDisplayName *parser; IPropertyBag *prop_bag; IMoniker *mon; @@ -968,11 +926,10 @@ static void test_vfw(void) ICGetInfo(hic, &info, sizeof(info)); ICClose(hic);
- lstrcpyW(buffer, deviceW); - lstrcatW(buffer, cmW); - StringFromGUID2(&CLSID_VideoCompressorCategory, buffer + lstrlenW(buffer), CHARS_IN_GUID); - lstrcatW(buffer, backslashW); - lstrcatW(buffer, name); + wcscpy(buffer, L"@device:cm:"); + StringFromGUID2(&CLSID_VideoCompressorCategory, buffer + wcslen(buffer), CHARS_IN_GUID); + wcscat(buffer, L"\"); + wcscat(buffer, name);
mon = check_display_name(parser, buffer);
@@ -980,24 +937,24 @@ static void test_vfw(void) ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
VariantInit(&var); - hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr);
- ok(!lstrcmpW(info.szDescription, V_BSTR(&var)), "expected %s, got %s\n", + ok(!wcscmp(info.szDescription, V_BSTR(&var)), "expected %s, got %s\n", wine_dbgstr_w(info.szDescription), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, clsidW, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr);
StringFromGUID2(&CLSID_AVICo, buffer, CHARS_IN_GUID); - ok(!lstrcmpW(buffer, V_BSTR(&var)), "expected %s, got %s\n", + ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n", wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var); - hr = IPropertyBag_Read(prop_bag, fcchandlerW, &var, NULL); + hr = IPropertyBag_Read(prop_bag, L"FccHandler", &var, NULL); ok(hr == S_OK, "Read failed: %#x\n", hr); - ok(!lstrcmpW(name, V_BSTR(&var)), "expected %s, got %s\n", + ok(!wcscmp(name, V_BSTR(&var)), "expected %s, got %s\n", wine_dbgstr_w(name), wine_dbgstr_w(V_BSTR(&var)));
VariantClear(&var);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/devenum/tests/devenum.c | 128 +++++++++++++++++++++++++++++++++-- 1 file changed, 124 insertions(+), 4 deletions(-)
diff --git a/dlls/devenum/tests/devenum.c b/dlls/devenum/tests/devenum.c index a666b2753b6..89f6f8d5bb7 100644 --- a/dlls/devenum/tests/devenum.c +++ b/dlls/devenum/tests/devenum.c @@ -310,8 +310,10 @@ static IMoniker *check_display_name_(int line, IParseDisplayName *parser, WCHAR
static void test_directshow_filter(void) { + SAFEARRAYBOUND bound = {.cElements = 10}; IParseDisplayName *parser; IPropertyBag *prop_bag; + void *array_data; IMoniker *mon; WCHAR buffer[200]; LRESULT res; @@ -348,9 +350,72 @@ static void test_directshow_filter(void) ok(find_moniker(&CLSID_AudioRendererCategory, mon), "filter should be registered\n");
VariantClear(&var); + V_VT(&var) = VT_EMPTY; hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); - ok(hr == S_OK, "Read failed: %#x\n", hr); - ok(!wcscmp(V_BSTR(&var), L"test"), "got %s\n", wine_dbgstr_w(V_BSTR(&var))); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(V_VT(&var) == VT_BSTR, "Got type %#x.\n", V_VT(&var)); + ok(!wcscmp(V_BSTR(&var), L"test"), "Got name %s.\n", wine_dbgstr_w(V_BSTR(&var))); + + VariantClear(&var); + V_VT(&var) = VT_LPWSTR; + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + V_VT(&var) = VT_BSTR; + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(V_VT(&var) == VT_BSTR, "Got type %#x.\n", V_VT(&var)); + ok(!wcscmp(V_BSTR(&var), L"test"), "Got name %s.\n", wine_dbgstr_w(V_BSTR(&var))); + + V_VT(&var) = VT_LPWSTR; + hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + VariantClear(&var); + + V_VT(&var) = VT_I4; + V_I4(&var) = 0xdeadbeef; + hr = IPropertyBag_Write(prop_bag, L"foobar", &var); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + V_VT(&var) = VT_EMPTY; + hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(V_VT(&var) == VT_I4, "Got type %#x.\n", V_VT(&var)); + ok(V_I4(&var) == 0xdeadbeef, "Got value %#x.\n", V_I4(&var)); + + V_VT(&var) = VT_UI4; + hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + V_VT(&var) = VT_BSTR; + hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + V_VT(&var) = VT_I4; + hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(V_VT(&var) == VT_I4, "Got type %#x.\n", V_VT(&var)); + ok(V_I4(&var) == 0xdeadbeef, "Got value %#x.\n", V_I4(&var)); + + V_VT(&var) = VT_UI4; + hr = IPropertyBag_Write(prop_bag, L"foobar", &var); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + V_VT(&var) = VT_ARRAY | VT_UI1; + V_ARRAY(&var) = SafeArrayCreate(VT_UI1, 1, &bound); + SafeArrayAccessData(V_ARRAY(&var), &array_data); + memcpy(array_data, "test data", 10); + SafeArrayUnaccessData(V_ARRAY(&var)); + hr = IPropertyBag_Write(prop_bag, L"foobar", &var); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + VariantClear(&var); + V_VT(&var) = VT_EMPTY; + hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(V_VT(&var) == (VT_ARRAY | VT_UI1), "Got type %#x.\n", V_VT(&var)); + SafeArrayAccessData(V_ARRAY(&var), &array_data); + ok(!memcmp(array_data, "test data", 10), "Got wrong data.\n"); + SafeArrayUnaccessData(V_ARRAY(&var));
IMoniker_Release(mon);
@@ -405,8 +470,10 @@ static void test_directshow_filter(void)
static void test_codec(void) { + SAFEARRAYBOUND bound = {.cElements = 10}; IParseDisplayName *parser; IPropertyBag *prop_bag; + void *array_data; IMoniker *mon; WCHAR buffer[200]; VARIANT var; @@ -436,10 +503,63 @@ static void test_codec(void) hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var); ok(hr == S_OK, "Write failed: %#x\n", hr);
+ V_VT(&var) = VT_LPWSTR; + hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + VariantClear(&var); + V_VT(&var) = VT_EMPTY; hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); - ok(hr == S_OK, "Read failed: %#x\n", hr); - ok(!wcscmp(V_BSTR(&var), L"test"), "got %s\n", wine_dbgstr_w(V_BSTR(&var))); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(V_VT(&var) == VT_BSTR, "Got type %#x.\n", V_VT(&var)); + ok(!wcscmp(V_BSTR(&var), L"test"), "Got name %s.\n", wine_dbgstr_w(V_BSTR(&var))); + + VariantClear(&var); + V_VT(&var) = VT_LPWSTR; + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + V_VT(&var) = VT_BSTR; + hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(V_VT(&var) == VT_BSTR, "Got type %#x.\n", V_VT(&var)); + ok(!wcscmp(V_BSTR(&var), L"test"), "Got name %s.\n", wine_dbgstr_w(V_BSTR(&var))); + + V_VT(&var) = VT_I4; + V_I4(&var) = 0xdeadbeef; + hr = IPropertyBag_Write(prop_bag, L"foobar", &var); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + V_VT(&var) = VT_EMPTY; + hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(V_VT(&var) == VT_I4, "Got type %#x.\n", V_VT(&var)); + ok(V_I4(&var) == 0xdeadbeef, "Got value %#x.\n", V_I4(&var)); + + V_VT(&var) = VT_UI4; + hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + V_VT(&var) = VT_BSTR; + hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + V_VT(&var) = VT_I4; + hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(V_VT(&var) == VT_I4, "Got type %#x.\n", V_VT(&var)); + ok(V_I4(&var) == 0xdeadbeef, "Got value %#x.\n", V_I4(&var)); + + V_VT(&var) = VT_UI4; + hr = IPropertyBag_Write(prop_bag, L"foobar", &var); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + V_VT(&var) = VT_ARRAY | VT_UI1; + V_ARRAY(&var) = SafeArrayCreate(VT_UI1, 1, &bound); + SafeArrayAccessData(V_ARRAY(&var), &array_data); + memcpy(array_data, "test data", 10); + SafeArrayUnaccessData(V_ARRAY(&var)); + hr = IPropertyBag_Write(prop_bag, L"foobar", &var); + ok(hr == S_OK, "Got hr %#x.\n", hr);
/* unlike DirectShow filters, these are automatically generated, so * enumerating them will destroy the key */
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/devenum/mediacatenum.c | 10 ++-------- dlls/devenum/tests/devenum.c | 4 ++-- 2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/dlls/devenum/mediacatenum.c b/dlls/devenum/mediacatenum.c index 4a5ae45e8b4..aab044cbad8 100644 --- a/dlls/devenum/mediacatenum.c +++ b/dlls/devenum/mediacatenum.c @@ -170,11 +170,6 @@ static HRESULT WINAPI property_bag_Read(IPropertyBag *iface, case REG_SZ: switch (V_VT(pVar)) { - case VT_LPWSTR: - V_BSTR(pVar) = CoTaskMemAlloc(received); - memcpy(V_BSTR(pVar), pData, received); - res = S_OK; - break; case VT_EMPTY: V_VT(pVar) = VT_BSTR; /* fall through */ @@ -261,7 +256,6 @@ static HRESULT WINAPI property_bag_Write(IPropertyBag *iface, switch (V_VT(pVar)) { case VT_BSTR: - case VT_LPWSTR: TRACE("writing %s\n", debugstr_w(V_BSTR(pVar))); lpData = V_BSTR(pVar); dwType = REG_SZ; @@ -481,13 +475,13 @@ static HRESULT WINAPI moniker_BindToObject(IMoniker *iface, IBindCtx *pbc, pProp = pvptr; if (SUCCEEDED(res)) { - V_VT(&var) = VT_LPWSTR; + V_VT(&var) = VT_BSTR; res = IPropertyBag_Read(pProp, clsidW, &var, NULL); } if (SUCCEEDED(res)) { res = CLSIDFromString(V_BSTR(&var), &clsID); - CoTaskMemFree(V_BSTR(&var)); + VariantClear(&var); } if (SUCCEEDED(res)) { diff --git a/dlls/devenum/tests/devenum.c b/dlls/devenum/tests/devenum.c index 89f6f8d5bb7..ce452e39044 100644 --- a/dlls/devenum/tests/devenum.c +++ b/dlls/devenum/tests/devenum.c @@ -359,7 +359,7 @@ static void test_directshow_filter(void) VariantClear(&var); V_VT(&var) = VT_LPWSTR; hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
V_VT(&var) = VT_BSTR; hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); @@ -517,7 +517,7 @@ static void test_codec(void) VariantClear(&var); V_VT(&var) = VT_LPWSTR; hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
V_VT(&var) = VT_BSTR; hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/devenum/mediacatenum.c | 6 ++---- dlls/devenum/tests/devenum.c | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/dlls/devenum/mediacatenum.c b/dlls/devenum/mediacatenum.c index aab044cbad8..cee2389617b 100644 --- a/dlls/devenum/mediacatenum.c +++ b/dlls/devenum/mediacatenum.c @@ -187,7 +187,6 @@ static HRESULT WINAPI property_bag_Read(IPropertyBag *iface, V_VT(pVar) = VT_I4; /* fall through */ case VT_I4: - case VT_UI4: V_I4(pVar) = *(DWORD *)pData; res = S_OK; break; @@ -262,9 +261,8 @@ static HRESULT WINAPI property_bag_Write(IPropertyBag *iface, cbData = (lstrlenW(V_BSTR(pVar)) + 1) * sizeof(WCHAR); break; case VT_I4: - case VT_UI4: - TRACE("writing %u\n", V_UI4(pVar)); - lpData = &V_UI4(pVar); + TRACE("writing %d\n", V_I4(pVar)); + lpData = &V_I4(pVar); dwType = REG_DWORD; cbData = sizeof(DWORD); break; diff --git a/dlls/devenum/tests/devenum.c b/dlls/devenum/tests/devenum.c index ce452e39044..6164efb7774 100644 --- a/dlls/devenum/tests/devenum.c +++ b/dlls/devenum/tests/devenum.c @@ -385,7 +385,7 @@ static void test_directshow_filter(void)
V_VT(&var) = VT_UI4; hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); V_VT(&var) = VT_BSTR; hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL); ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); @@ -538,7 +538,7 @@ static void test_codec(void)
V_VT(&var) = VT_UI4; hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); V_VT(&var) = VT_BSTR; hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL); ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/devenum/devenum_private.h | 2 + dlls/devenum/mediacatenum.c | 401 ++++++++++++++------------------- 2 files changed, 170 insertions(+), 233 deletions(-)
diff --git a/dlls/devenum/devenum_private.h b/dlls/devenum/devenum_private.h index cb274d6c11b..6d969ff6082 100644 --- a/dlls/devenum/devenum_private.h +++ b/dlls/devenum/devenum_private.h @@ -66,6 +66,8 @@ struct moniker WCHAR *name; /* for filters and codecs */ CLSID clsid; /* for DMOs */ }; + + IPropertyBag IPropertyBag_iface; };
struct moniker *dmo_moniker_create(const GUID class, const GUID clsid) DECLSPEC_HIDDEN; diff --git a/dlls/devenum/mediacatenum.c b/dlls/devenum/mediacatenum.c index cee2389617b..569baffb216 100644 --- a/dlls/devenum/mediacatenum.c +++ b/dlls/devenum/mediacatenum.c @@ -43,263 +43,233 @@ typedef struct DWORD cm_index; } EnumMonikerImpl;
-typedef struct -{ - IPropertyBag IPropertyBag_iface; - LONG ref; - enum device_type type; - union - { - WCHAR path[MAX_PATH]; /* for filters and codecs */ - CLSID clsid; /* for DMOs */ - }; -} RegPropBagImpl; - - -static inline RegPropBagImpl *impl_from_IPropertyBag(IPropertyBag *iface) +static inline struct moniker *impl_from_IPropertyBag(IPropertyBag *iface) { - return CONTAINING_RECORD(iface, RegPropBagImpl, IPropertyBag_iface); + return CONTAINING_RECORD(iface, struct moniker, IPropertyBag_iface); }
-static HRESULT WINAPI property_bag_QueryInterface(IPropertyBag *iface, REFIID riid, void **ppvObj) +static HRESULT WINAPI property_bag_QueryInterface(IPropertyBag *iface, REFIID iid, void **out) { - RegPropBagImpl *This = impl_from_IPropertyBag(iface); + struct moniker *moniker = impl_from_IPropertyBag(iface);
- TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppvObj); + TRACE("moniker %p, iid %s, out %p.\n", moniker, debugstr_guid(iid), out);
- if (This == NULL || ppvObj == NULL) return E_POINTER; + if (!out) + return E_POINTER;
- if (IsEqualGUID(riid, &IID_IUnknown) || - IsEqualGUID(riid, &IID_IPropertyBag)) + if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IPropertyBag)) { - *ppvObj = iface; + *out = iface; IPropertyBag_AddRef(iface); return S_OK; }
- FIXME("- no interface IID: %s\n", debugstr_guid(riid)); + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + *out = NULL; return E_NOINTERFACE; }
static ULONG WINAPI property_bag_AddRef(IPropertyBag *iface) { - RegPropBagImpl *This = impl_from_IPropertyBag(iface); - - TRACE("(%p)->() AddRef from %d\n", iface, This->ref); - - return InterlockedIncrement(&This->ref); + struct moniker *moniker = impl_from_IPropertyBag(iface); + return IMoniker_AddRef(&moniker->IMoniker_iface); }
static ULONG WINAPI property_bag_Release(IPropertyBag *iface) { - RegPropBagImpl *This = impl_from_IPropertyBag(iface); - ULONG ref; - - TRACE("(%p)->() ReleaseThis->ref from %d\n", iface, This->ref); - - ref = InterlockedDecrement(&This->ref); - if (ref == 0) { - CoTaskMemFree(This); - DEVENUM_UnlockModule(); - } - return ref; + struct moniker *moniker = impl_from_IPropertyBag(iface); + return IMoniker_Release(&moniker->IMoniker_iface); }
static HRESULT WINAPI property_bag_Read(IPropertyBag *iface, - const WCHAR *pszPropName, VARIANT *pVar, IErrorLog *pErrorLog) -{ - static const WCHAR FriendlyNameW[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0}; - LPVOID pData = NULL; - DWORD received; - DWORD type = 0; - RegPropBagImpl *This = impl_from_IPropertyBag(iface); - HRESULT res = S_OK; - LONG reswin32 = ERROR_SUCCESS; - WCHAR name[80]; - HKEY hkey; + const WCHAR *name, VARIANT *var, IErrorLog *errorlog) +{ + struct moniker *moniker = impl_from_IPropertyBag(iface); + WCHAR dmo_name[80]; + DWORD size, type; + HKEY parent, key; + WCHAR path[78]; + void *data; + HRESULT hr; + LONG ret;
- TRACE("(%p)->(%s, %p, %p)\n", This, debugstr_w(pszPropName), pVar, pErrorLog); + TRACE("moniker %p, name %s, var %p, errorlog %p.\n", moniker, debugstr_w(name), var, errorlog);
- if (!pszPropName || !pVar) + if (!name || !var) return E_POINTER;
- if (This->type == DEVICE_DMO) + if (moniker->type == DEVICE_DMO) { - if (!lstrcmpW(pszPropName, FriendlyNameW)) + if (!wcscmp(name, L"FriendlyName")) { - res = DMOGetName(&This->clsid, name); - if (SUCCEEDED(res)) + if (SUCCEEDED(hr = DMOGetName(&moniker->clsid, dmo_name))) { - V_VT(pVar) = VT_BSTR; - V_BSTR(pVar) = SysAllocString(name); + V_VT(var) = VT_BSTR; + V_BSTR(var) = SysAllocString(dmo_name); } - return res; + return hr; } return HRESULT_FROM_WIN32(ERROR_NOT_FOUND); }
- if (This->type == DEVICE_FILTER) - reswin32 = RegOpenKeyW(HKEY_CLASSES_ROOT, This->path, &hkey); - else if (This->type == DEVICE_CODEC) - reswin32 = RegOpenKeyW(HKEY_CURRENT_USER, This->path, &hkey); - res = HRESULT_FROM_WIN32(reswin32); - - if (SUCCEEDED(res)) + if (moniker->type == DEVICE_FILTER) { - reswin32 = RegQueryValueExW(hkey, pszPropName, NULL, NULL, NULL, &received); - res = HRESULT_FROM_WIN32(reswin32); + wcscpy(path, L"CLSID\"); + if (moniker->has_class) + { + StringFromGUID2(&moniker->class, path + wcslen(path), CHARS_IN_GUID); + wcscat(path, L"\Instance"); + } + if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, path, 0, 0, &parent))) + return HRESULT_FROM_WIN32(ret); } - - if (SUCCEEDED(res)) + else if (moniker->type == DEVICE_CODEC) { - pData = HeapAlloc(GetProcessHeap(), 0, received); - - /* work around a GCC bug that occurs here unless we use the reswin32 variable as well */ - reswin32 = RegQueryValueExW(hkey, pszPropName, NULL, &type, pData, &received); - res = HRESULT_FROM_WIN32(reswin32); + wcscpy(path, L"Software\Microsoft\ActiveMovie\devenum\"); + if (moniker->has_class) + StringFromGUID2(&moniker->class, path + wcslen(path), CHARS_IN_GUID); + if ((ret = RegOpenKeyExW(HKEY_CURRENT_USER, path, 0, 0, &parent))) + return HRESULT_FROM_WIN32(ret); } + ret = RegOpenKeyExW(parent, moniker->name, 0, KEY_READ, &key); + RegCloseKey(parent); + if (ret) + return HRESULT_FROM_WIN32(ret);
- if (SUCCEEDED(res)) + if ((ret = RegQueryValueExW(key, name, NULL, NULL, NULL, &size))) { - res = E_INVALIDARG; /* assume we cannot coerce into right type */ + RegCloseKey(key); + return HRESULT_FROM_WIN32(ret); + }
- TRACE("Read %d bytes (%s)\n", received, type == REG_SZ ? debugstr_w(pData) : "binary data"); + data = malloc(size); + if ((ret = RegQueryValueExW(key, name, NULL, &type, data, &size))) + { + RegCloseKey(key); + free(data); + return HRESULT_FROM_WIN32(ret); + } + RegCloseKey(key);
- switch (type) + switch (type) + { + case REG_SZ: + if (V_VT(var) == VT_EMPTY) + V_VT(var) = VT_BSTR; + if (V_VT(var) != VT_BSTR) { - case REG_SZ: - switch (V_VT(pVar)) - { - case VT_EMPTY: - V_VT(pVar) = VT_BSTR; - /* fall through */ - case VT_BSTR: - V_BSTR(pVar) = SysAllocStringLen(pData, received/sizeof(WCHAR) - 1); - res = S_OK; - break; - } - break; - case REG_DWORD: - TRACE("REG_DWORD: %x\n", *(DWORD *)pData); - switch (V_VT(pVar)) - { - case VT_EMPTY: - V_VT(pVar) = VT_I4; - /* fall through */ - case VT_I4: - V_I4(pVar) = *(DWORD *)pData; - res = S_OK; - break; - } - break; - case REG_BINARY: - { - SAFEARRAYBOUND bound; - void * pArrayElements; - bound.lLbound = 0; - bound.cElements = received; - TRACE("REG_BINARY: len = %d\n", received); - switch (V_VT(pVar)) - { - case VT_EMPTY: - V_VT(pVar) = VT_ARRAY | VT_UI1; - /* fall through */ - case VT_ARRAY | VT_UI1: - if (!(V_ARRAY(pVar) = SafeArrayCreate(VT_UI1, 1, &bound))) - res = E_OUTOFMEMORY; - else - res = S_OK; - break; - } - - if (res == E_INVALIDARG) - break; - - res = SafeArrayAccessData(V_ARRAY(pVar), &pArrayElements); - if (FAILED(res)) - break; - - CopyMemory(pArrayElements, pData, received); - res = SafeArrayUnaccessData(V_ARRAY(pVar)); - break; - } + WARN("Invalid type %s.\n", debugstr_vt(V_VT(var))); + return E_INVALIDARG; } - if (res == E_INVALIDARG) - FIXME("Variant type %x not supported for regtype %x\n", V_VT(pVar), type); - } + V_BSTR(var) = SysAllocStringLen(data, size / sizeof(WCHAR) - 1); + free(data); + return S_OK; + case REG_DWORD: + if (V_VT(var) == VT_EMPTY) + V_VT(var) = VT_I4; + if (V_VT(var) != VT_I4) + { + WARN("Invalid type %s.\n", debugstr_vt(V_VT(var))); + return E_INVALIDARG; + } + V_I4(var) = *(DWORD *)data; + free(data); + return S_OK; + case REG_BINARY: + { + SAFEARRAYBOUND bound = {.cElements = size}; + void *array_data;
- HeapFree(GetProcessHeap(), 0, pData); + if (V_VT(var) == VT_EMPTY) + V_VT(var) = VT_ARRAY | VT_UI1; + if (V_VT(var) != (VT_ARRAY | VT_UI1)) + { + WARN("Invalid type %s.\n", debugstr_vt(V_VT(var))); + return E_INVALIDARG; + }
- RegCloseKey(hkey); + if (!(V_ARRAY(var) = SafeArrayCreate(VT_UI1, 1, &bound))) + { + free(data); + return E_OUTOFMEMORY; + }
- TRACE("<- %x\n", res); - return res; + SafeArrayAccessData(V_ARRAY(var), &array_data); + memcpy(array_data, data, size); + SafeArrayUnaccessData(V_ARRAY(var)); + free(data); + return S_OK; + } + default: + FIXME("Unhandled type %#x.\n", type); + free(data); + return E_NOTIMPL; + } }
-static HRESULT WINAPI property_bag_Write(IPropertyBag *iface, - const WCHAR *pszPropName, VARIANT *pVar) +static HRESULT WINAPI property_bag_Write(IPropertyBag *iface, const WCHAR *name, VARIANT *var) { - RegPropBagImpl *This = impl_from_IPropertyBag(iface); - LPVOID lpData = NULL; - DWORD cbData = 0; - DWORD dwType = 0; - HRESULT res = S_OK; - LONG lres = ERROR_SUCCESS; - HKEY hkey; + struct moniker *moniker = impl_from_IPropertyBag(iface); + HKEY parent, key; + WCHAR path[78]; + LONG ret;
- TRACE("(%p)->(%s, %p)\n", This, debugstr_w(pszPropName), pVar); + TRACE("moniker %p, name %s, var %s.\n", moniker, debugstr_w(name), debugstr_variant(var));
- if (This->type == DEVICE_DMO) + if (moniker->type == DEVICE_DMO) return E_ACCESSDENIED;
- switch (V_VT(pVar)) + if (moniker->type == DEVICE_FILTER) + { + wcscpy(path, L"CLSID\"); + if (moniker->has_class) + { + StringFromGUID2(&moniker->class, path + wcslen(path), CHARS_IN_GUID); + wcscat(path, L"\Instance"); + } + if ((ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, path, 0, NULL, 0, 0, NULL, &parent, NULL))) + return HRESULT_FROM_WIN32(ret); + } + else if (moniker->type == DEVICE_CODEC) + { + wcscpy(path, L"Software\Microsoft\ActiveMovie\devenum\"); + if (moniker->has_class) + StringFromGUID2(&moniker->class, path + wcslen(path), CHARS_IN_GUID); + if ((ret = RegCreateKeyExW(HKEY_CURRENT_USER, path, 0, NULL, 0, 0, NULL, &parent, NULL))) + return HRESULT_FROM_WIN32(ret); + } + ret = RegCreateKeyExW(parent, moniker->name, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL); + RegCloseKey(parent); + if (ret) + return HRESULT_FROM_WIN32(ret); + + switch (V_VT(var)) { case VT_BSTR: - TRACE("writing %s\n", debugstr_w(V_BSTR(pVar))); - lpData = V_BSTR(pVar); - dwType = REG_SZ; - cbData = (lstrlenW(V_BSTR(pVar)) + 1) * sizeof(WCHAR); + ret = RegSetValueExW(key, name, 0, REG_SZ, (BYTE *)V_BSTR(var), + (wcslen(V_BSTR(var)) + 1) * sizeof(WCHAR)); break; case VT_I4: - TRACE("writing %d\n", V_I4(pVar)); - lpData = &V_I4(pVar); - dwType = REG_DWORD; - cbData = sizeof(DWORD); + ret = RegSetValueExW(key, name, 0, REG_DWORD, (BYTE *)&V_I4(var), sizeof(DWORD)); break; case VT_ARRAY | VT_UI1: { - LONG lUbound = 0; - LONG lLbound = 0; - dwType = REG_BINARY; - res = SafeArrayGetLBound(V_ARRAY(pVar), 1, &lLbound); - res = SafeArrayGetUBound(V_ARRAY(pVar), 1, &lUbound); - cbData = (lUbound - lLbound + 1) /* * sizeof(BYTE)*/; - TRACE("cbData: %d\n", cbData); - res = SafeArrayAccessData(V_ARRAY(pVar), &lpData); + LONG lbound, ubound; + void *array_data; + SafeArrayGetLBound(V_ARRAY(var), 1, &lbound); + SafeArrayGetUBound(V_ARRAY(var), 1, &ubound); + SafeArrayAccessData(V_ARRAY(var), &array_data); + ret = RegSetValueExW(key, name, 0, REG_BINARY, array_data, ubound - lbound + 1); + SafeArrayUnaccessData(V_ARRAY(var)); break; } default: - FIXME("Variant type %d not handled\n", V_VT(pVar)); + WARN("Unhandled type %s.\n", debugstr_vt(V_VT(var))); return E_FAIL; }
- if (This->type == DEVICE_FILTER) - lres = RegCreateKeyW(HKEY_CLASSES_ROOT, This->path, &hkey); - else if (This->type == DEVICE_CODEC) - lres = RegCreateKeyW(HKEY_CURRENT_USER, This->path, &hkey); - res = HRESULT_FROM_WIN32(lres); - - if (SUCCEEDED(res)) - { - lres = RegSetValueExW(hkey, pszPropName, 0, dwType, lpData, cbData); - res = HRESULT_FROM_WIN32(lres); - RegCloseKey(hkey); - } - - if (V_VT(pVar) & VT_ARRAY) - res = SafeArrayUnaccessData(V_ARRAY(pVar)); - - return res; + RegCloseKey(key); + return S_OK; }
static const IPropertyBagVtbl IPropertyBag_Vtbl = @@ -311,46 +281,6 @@ static const IPropertyBagVtbl IPropertyBag_Vtbl = property_bag_Write, };
-static HRESULT property_bag_create(struct moniker *mon, IPropertyBag **ppBag) -{ - RegPropBagImpl * rpb = CoTaskMemAlloc(sizeof(RegPropBagImpl)); - if (!rpb) - return E_OUTOFMEMORY; - rpb->IPropertyBag_iface.lpVtbl = &IPropertyBag_Vtbl; - rpb->ref = 1; - rpb->type = mon->type; - - if (rpb->type == DEVICE_DMO) - rpb->clsid = mon->clsid; - else if (rpb->type == DEVICE_FILTER) - { - lstrcpyW(rpb->path, clsidW); - lstrcatW(rpb->path, backslashW); - if (mon->has_class) - { - StringFromGUID2(&mon->class, rpb->path + lstrlenW(rpb->path), CHARS_IN_GUID); - lstrcatW(rpb->path, instanceW); - lstrcatW(rpb->path, backslashW); - } - lstrcatW(rpb->path, mon->name); - } - else if (rpb->type == DEVICE_CODEC) - { - lstrcpyW(rpb->path, wszActiveMovieKey); - if (mon->has_class) - { - StringFromGUID2(&mon->class, rpb->path + lstrlenW(rpb->path), CHARS_IN_GUID); - lstrcatW(rpb->path, backslashW); - } - lstrcatW(rpb->path, mon->name); - } - - *ppBag = &rpb->IPropertyBag_iface; - DEVENUM_LockModule(); - return S_OK; -} - - static inline struct moniker *impl_from_IMoniker(IMoniker *iface) { return CONTAINING_RECORD(iface, struct moniker, IMoniker_iface); @@ -517,13 +447,13 @@ static HRESULT WINAPI moniker_BindToObject(IMoniker *iface, IBindCtx *pbc, }
static HRESULT WINAPI moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, - IMoniker *pmkToLeft, REFIID riid, void **ppvObj) + IMoniker *pmkToLeft, REFIID riid, void **out) { - struct moniker *This = impl_from_IMoniker(iface); + struct moniker *moniker = impl_from_IMoniker(iface);
- TRACE("(%p)->(%p, %p, %s, %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObj); + TRACE("moniker %p, left %p, iid %s, out %p.\n", moniker, pmkToLeft, debugstr_guid(riid), out);
- *ppvObj = NULL; + *out = NULL;
if (pmkToLeft) return MK_E_NOSTORAGE; @@ -540,7 +470,9 @@ static HRESULT WINAPI moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc,
if (IsEqualGUID(riid, &IID_IPropertyBag)) { - return property_bag_create(This, (IPropertyBag **)ppvObj); + *out = &moniker->IPropertyBag_iface; + IPropertyBag_AddRef(&moniker->IPropertyBag_iface); + return S_OK; }
return MK_E_NOSTORAGE; @@ -768,6 +700,7 @@ struct moniker *filter_moniker_create(const GUID *class, const WCHAR *name) return NULL;
object->IMoniker_iface.lpVtbl = &IMoniker_Vtbl; + object->IPropertyBag_iface.lpVtbl = &IPropertyBag_Vtbl; object->ref = 1; object->type = DEVICE_FILTER; if (class) @@ -788,6 +721,7 @@ struct moniker *codec_moniker_create(const GUID *class, const WCHAR *name) return NULL;
object->IMoniker_iface.lpVtbl = &IMoniker_Vtbl; + object->IPropertyBag_iface.lpVtbl = &IPropertyBag_Vtbl; object->ref = 1; object->type = DEVICE_CODEC; if (class) @@ -808,6 +742,7 @@ struct moniker *dmo_moniker_create(const GUID class, const GUID clsid) return NULL;
object->IMoniker_iface.lpVtbl = &IMoniker_Vtbl; + object->IPropertyBag_iface.lpVtbl = &IPropertyBag_Vtbl; object->ref = 1; object->type = DEVICE_DMO; object->class = class;