[PATCH] Correct AssocCreate and tests
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Fri Mar 6 03:18:04 CST 2009
---
dlls/shlwapi/assoc.c | 6 ++++--
dlls/shlwapi/shlwapi.spec | 2 +-
dlls/shlwapi/tests/assoc.c | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/dlls/shlwapi/assoc.c b/dlls/shlwapi/assoc.c
index d13f0aa..405effe 100644
--- a/dlls/shlwapi/assoc.c
+++ b/dlls/shlwapi/assoc.c
@@ -134,6 +134,7 @@ static BOOL SHLWAPI_ParamAToW(LPCSTR lpszParam, LPWSTR lpszBuff, DWORD dwLen,
* Failure: An HRESULT error code indicating the error.
*
* NOTES
+ * clsid must be equal to CLSID_QueryAssociations and
* refiid must be equal to IID_IQueryAssociations, or this function will fail.
*/
HRESULT WINAPI AssocCreate(CLSID clsid, REFIID refiid, void **lpInterface)
@@ -149,8 +150,9 @@ HRESULT WINAPI AssocCreate(CLSID clsid, REFIID refiid, void **lpInterface)
*(DWORD*)lpInterface = 0;
- if (!IsEqualGUID(&clsid, &IID_IQueryAssociations))
- return E_NOTIMPL;
+ if (!IsEqualGUID(&clsid, &CLSID_QueryAssociations) ||
+ !IsEqualGUID(refiid, &IID_IQueryAssociations))
+ return CLASS_E_CLASSNOTAVAILABLE;
lpAssoc = IQueryAssociations_Constructor();
diff --git a/dlls/shlwapi/shlwapi.spec b/dlls/shlwapi/shlwapi.spec
index 0b1cd4c..aecb104 100644
--- a/dlls/shlwapi/shlwapi.spec
+++ b/dlls/shlwapi/shlwapi.spec
@@ -546,7 +546,7 @@
550 stub -noname GetTemplateInfoFromHandle
551 stub -noname IShellFolder_CompareIDs
-@ stdcall AssocCreate(double double ptr ptr)
+@ stdcall AssocCreate(ptr ptr ptr)
@ stdcall AssocIsDangerous(long)
@ stdcall AssocQueryKeyA(long long str ptr ptr)
@ stdcall AssocQueryKeyW(long long wstr ptr ptr)
diff --git a/dlls/shlwapi/tests/assoc.c b/dlls/shlwapi/tests/assoc.c
index 3799ecc..face496 100644
--- a/dlls/shlwapi/tests/assoc.c
+++ b/dlls/shlwapi/tests/assoc.c
@@ -21,12 +21,14 @@
#include "wine/test.h"
#include "shlwapi.h"
+#include "shlguid.h"
#define expect(expected, got) ok ( expected == got, "Expected %d, got %d\n", expected, got)
#define expect_hr(expected, got) ok ( expected == got, "Expected %08x, got %08x\n", expected, got)
static HRESULT (WINAPI *pAssocQueryStringA)(ASSOCF,ASSOCSTR,LPCSTR,LPCSTR,LPSTR,LPDWORD) = NULL;
static HRESULT (WINAPI *pAssocQueryStringW)(ASSOCF,ASSOCSTR,LPCWSTR,LPCWSTR,LPWSTR,LPDWORD) = NULL;
+static HRESULT (WINAPI *pAssocCreate)(CLSID, REFIID, void **) = NULL;
/* Every version of Windows with IE should have this association? */
static const WCHAR dotHtml[] = { '.','h','t','m','l',0 };
@@ -235,14 +237,48 @@ cleanup:
}
+static void test_assoc_create(void)
+{
+ HRESULT hr;
+ IQueryAssociations *pqa;
+
+ if (!pAssocCreate)
+ {
+ win_skip("AssocCreate() is missing\n");
+ return;
+ }
+
+ hr = pAssocCreate(IID_NULL, &IID_NULL, NULL);
+ ok(hr == E_INVALIDARG, "Unexpected result : %08x\n", hr);
+
+ hr = pAssocCreate(CLSID_QueryAssociations, &IID_NULL, (LPVOID*)&pqa);
+ ok(hr == CLASS_E_CLASSNOTAVAILABLE || hr == E_NOTIMPL /* win98 */
+ , "Unexpected result : %08x\n", hr);
+
+ hr = pAssocCreate(IID_NULL, &IID_IQueryAssociations, (LPVOID*)&pqa);
+ ok(hr == CLASS_E_CLASSNOTAVAILABLE || hr == E_NOTIMPL /* win98 */
+ , "Unexpected result : %08x\n", hr);
+
+ hr = pAssocCreate(CLSID_QueryAssociations, &IID_IQueryAssociations, (LPVOID*)&pqa);
+ ok(hr == S_OK || hr == E_NOTIMPL /* win98 */
+ , "Unexpected result : %08x\n", hr);
+ if(hr == S_OK)
+ {
+ IQueryAssociations_Release(pqa);
+ }
+
+}
+
START_TEST(assoc)
{
HMODULE hshlwapi;
hshlwapi = GetModuleHandleA("shlwapi.dll");
pAssocQueryStringA = (void*)GetProcAddress(hshlwapi, "AssocQueryStringA");
pAssocQueryStringW = (void*)GetProcAddress(hshlwapi, "AssocQueryStringW");
+ pAssocCreate = (void*)GetProcAddress(hshlwapi, "AssocCreate");
test_getstring_bad();
test_getstring_basic();
test_getstring_no_extra();
+ test_assoc_create();
}
--
1.5.4.3
--------------080507060102030002030602--
More information about the wine-patches
mailing list