以下情况:
我有一个工作的V1 CP,它实现了IConnectableCredentialProviderCredential
接口。这种依赖关系对于访问我需要的IQueryContinueWithStatus
接口是必要的。
class CCredential : public IConnectableCredentialProviderCredential
{
[...]
IConnectableCredentialProviderCredential
实施ICredentialProviderCredential
。
使用此代码段完成COM IUknown
查询方法:
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)
是不可取的,因为如果请求CredUI,则qitOnlyCredUI
是必需的,这不支持IQueryContinueWithStatus
。
class CCredential : public IConnectableCredentialProviderCredential,
public ICredentialProviderCredential2,
public ICredentialProviderCredentialWithFieldOptions
{
[...]
ICredentialProviderCredential2
实施ICredentialProviderCredential
。
实现COM QueryInterface
方法,如:
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
基类的模糊定义。
有关如何实现这一目标的任何想法?
答案 0 :(得分:1)
您需要为您的案例使用QITABENTMULTI()
宏。它记录在shlwapi.h
中。我不知道为什么它不在MSDN上。