将变量分配给变量

时间:2012-09-05 18:25:43

标签: c++ winapi variant

我想将Flag设置为navOpenInBackgroundTab of BrowserNavConstants enum,很快将其作为参数传递给IWebBrowser2::Navigate2 Method

IWebBrowser2::Navigate2的签名: -

HRESULT Navigate2(
    VARIANT *URL,
    VARIANT *Flags,
    VARIANT *TargetFrameName,
    VARIANT *PostData,
    VARIANT *Headers
);

这是我遇到问题的地方: -

VARIANT SITE={0}, vFlags = {0},vTargetFrameName = {0},vPostData = {0},vHeaders = {0};
...
...
vFlags.intVal=navOpenInBackgroundTab;//<--Here,Don't know how to do it.Not Working..

m_spWebBrowser->Navigate2(&SITE, &vFlags,&vTargetFrameName, &vPostData, &vHeaders);

非常感谢您的支持。

1 个答案:

答案 0 :(得分:0)

使用InitVariantFromInt32: -

HRESULT hr = InitVariantFromInt32(navOpenInBackgroundTab, &vFlags);

您也可以使用(来自我的旧代码库:)): -

V_VT(&vFlags) = VT_I4;
V_I4(&vFlags) = navOpenInBackgroundTab;