0

以下情况:

我有一个实现IConnectableCredentialProviderCredential接口的工作 V1 CP。这种依赖关系是访问IQueryContinueWithStatus我需要的接口所必需的。

class CCredential : public IConnectableCredentialProviderCredential
{
    [...]

IConnectableCredentialProviderCredential实现ICredentialProviderCredential

COMIUknown查询方法是使用以下代码段完成的:

IFACEMETHODIMP QueryInterface(__in REFIID riid, __deref_out void** ppv)
{
    static const QITAB qitOnlyCredUI[] =
    {
        QITABENT(CCredential, ICredentialProviderCredential),
        { 0 },
    };

    static const QITAB qitFull[] =
    {
        QITABENT(CCredential, ICredentialProviderCredential), // IID_ICredentialProviderCredential
        QITABENT(CCredential, IConnectableCredentialProviderCredential), // IID_IConnectableCredentialProviderCredential            
        { 0 },
    };

[...]

现在我想将提供程序迁移为 V2 CP 并实现ICredentialProviderCredential2接口,但保持与IQueryContinueWithStatus接口兼容。此外,QITABENT(CCredential, ICredentialProviderCredential)退出不是选项,因为qitOnlyCredUI在请求不支持的 CredUI 时是必需的IQueryContinueWithStatus

class CCredential : public IConnectableCredentialProviderCredential,
                    public ICredentialProviderCredential2,
                    public ICredentialProviderCredentialWithFieldOptions
{
    [...]

ICredentialProviderCredential2实现ICredentialProviderCredential

实现 COMQueryInterface方法,如:

IFACEMETHODIMP QueryInterface(__in REFIID riid, __deref_out void** ppv)
{
    static const QITAB qitOnlyCredUI[] =
    {
        QITABENT(CCredential, ICredentialProviderCredential),
        { 0 },
    };

    static const QITAB qitFull[] =
    {
        QITABENT(CCredential, ICredentialProviderCredential), // IID_ICredentialProviderCredential
        QITABENT(CCredential, ICredentialProviderCredential2), // IID_ICredentialProviderCredential2
        QITABENT(CCredential, IConnectableCredentialProviderCredential), // IID_IConnectableCredentialProviderCredential            
        QITABENT(CCredential, ICredentialProviderCredentialWithFieldOptions), //IID_ICredentialProviderCredentialWithFieldOptions
        { 0 },
    };

这就是钻石问题开始的地方,因为ICredentialProviderCredential2两者IConnectableCredentialProviderCredential都实施ICredentialProviderCredential

尝试编译肯定会导致编译器抱怨ICredentialProviderCredential基类的定义不明确。

任何想法如何实现?

4

1 回答 1

1

您将需要QITABENTMULTI()为您的案例使用宏。它记录在shlwapi.h. 我不知道为什么它不在 MSDN 上。

于 2015-12-16T19:25:30.110 回答