gpt4 book ai didi

c++ - 使用 Windows V2 凭据提供程序的菱形继承(钻石问题)

转载 作者:行者123 更新时间:2023-11-28 05:55:09 25 4
gpt4 key购买 nike

以下情况:

我有一个工作的 V1 CP,它实现了 IConnectableCredentialProviderCredential 接口(interface)。此依赖项是访问我需要的 IQueryContinueWithStatus 接口(interface)所必需的。

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 接口(interface),但与 IQueryContinueWithStatus 接口(interface)保持兼容。此外,删除 QITABENT(CCredential, ICredentialProviderCredential) 是不可取的,因为 qitOnlyCredUI 是必需的,以防请求 CredUI,它不支持 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 },
};

这是菱形继承(钻石问题)开始的地方,因为 ICredentialProviderCredential2IConnectableCredentialProviderCredential 都实现了 ICredentialProviderCredential

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

有什么想法可以实现吗?

最佳答案

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

关于c++ - 使用 Windows V2 凭据提供程序的菱形继承(钻石问题),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34319824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com