本文整理汇总了C++中CComVariant::Detach方法的典型用法代码示例。如果您正苦于以下问题:C++ CComVariant::Detach方法的具体用法?C++ CComVariant::Detach怎么用?C++ CComVariant::Detach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComVariant
的用法示例。
在下文中一共展示了CComVariant::Detach方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecJScript
HRESULT vmsDomHelper::ExecJScript(IHTMLDocument *pDoc, BSTR bstrFuncName, const vector <CComVariant>& vArgs, CComVariant &vaResult)
{
ATLASSERT (pDoc != NULL);
if (!pDoc)
return E_INVALIDARG;
IDispatchPtr spScript;
HRESULT hr = pDoc->get_Script (&spScript);
if (spScript == NULL)
return hr;
DISPID did = NULL;
hr = spScript->GetIDsOfNames (IID_NULL, &bstrFuncName, 1, LOCALE_SYSTEM_DEFAULT, &did);
if (FAILED (hr))
return hr;
DISPPARAMS dparams;
ZeroMemory (&dparams, sizeof (dparams));
dparams.cArgs = vArgs.size ();
if (dparams.cArgs)
dparams.rgvarg = new VARIANT [dparams.cArgs];
for (int i = 0; i < vArgs.size (); i++)
{
CComVariant vaTmp; vaTmp.Copy (&vArgs [vArgs.size () - i - 1]);
VariantInit (&dparams.rgvarg [i]);
vaTmp.Detach (&dparams.rgvarg [i]);
}
EXCEPINFO ei;
ZeroMemory (&ei, sizeof (ei));
UINT nArgErr = (UINT)-1;
hr = spScript->Invoke (did, IID_NULL, 0, DISPATCH_METHOD, &dparams, &vaResult, &ei, &nArgErr);
if (dparams.rgvarg)
{
for (int i = 0; i < dparams.cArgs; i++)
VariantClear (&dparams.rgvarg [i]);
delete [] dparams.rgvarg;
}
return hr;
}
示例2: PCSoftRunDefault
HRESULT CMainDlg::PCSoftRunDefault(DISPID dispIdMember, DISPPARAMS *pDispParams, VARIANT *pVarResult)
{
CComVariant retVal;
//if(pDispParams->rgvarg[0].bstrVal == NULL || pDispParams->rgvarg[0].bstrVal[0] == L'\0')
//{
// retVal = false;
//}
//else
{
ShowWindow(FALSE);
//CString strCmd;
//strCmd = pDispParams->rgvarg[0].bstrVal;
OnBkBtnDefault();
OnBkBtnClose();
//::PostMessage(this->m_hWnd, WM_CLOSE, 0, 0);
retVal = true;
}
if(pVarResult != NULL)
{
retVal.Detach(pVarResult);
}
return S_OK;
}
示例3: PCSoftOpenDownedSoft
HRESULT CMainDlg::PCSoftOpenDownedSoft(DISPID dispIdMember, DISPPARAMS *pDispParams, VARIANT *pVarResult)
{
CString strCmdLine;
BKSafeConfig::GetStoreDir(strCmdLine);
::SHCreateDirectory(NULL, strCmdLine);
CComVariant retVal;
if(pDispParams->rgvarg[0].bstrVal == NULL || pDispParams->rgvarg[0].bstrVal[0] == L'\0')
{
retVal = true;
::ShellExecute(NULL, L"open", strCmdLine, NULL, NULL, SW_SHOWNORMAL);
}
else
{
strCmdLine = _PathAddBackslash(strCmdLine) + pDispParams->rgvarg[0].bstrVal;
BOOL bExist = ::PathFileExists(strCmdLine);
if(bExist)
{
strCmdLine = L"/select," + strCmdLine;
::ShellExecute(NULL, NULL, L"explorer.exe", strCmdLine, NULL, SW_NORMAL);
}
retVal = (bExist ? true : false);
}
if(pVarResult != NULL)
{
retVal.Detach(pVarResult);
}
return S_OK;
}
示例4: PCSoftResumeDown
HRESULT CMainDlg::PCSoftResumeDown(DISPID dispIdMember, DISPPARAMS *pDispParams, VARIANT *pVarResult)
{
CComVariant retVal = false;
do
{
LONG id = safe_atol(pDispParams->rgvarg[0].bstrVal);
if(id == 0)
{
break;
}
CriticalSectionScoped locker(m_csPhoneNess);
IDTManager *pDTMgr = GetDTMgrForPhone();
if(pDTMgr != NULL)
{
Id2PhoneSoftIter itSoft = m_id2PhoneSoft.Lookup(id);
if(itSoft != NULL)
{
pDTMgr->ResumeTask(itSoft->m_value.idDown);
retVal = true;
}
}
}
while(FALSE);
if(pVarResult != NULL)
{
retVal.Detach(pVarResult);
}
return S_OK;
}
示例5: PCSoftExists
HRESULT CMainDlg::PCSoftExists(DISPID dispIdMember, DISPPARAMS *pDispParams, VARIANT *pVarResult)
{
CString strStore;
BKSafeConfig::GetStoreDir(strStore);
strStore = _PathAddBackslash(strStore) + pDispParams->rgvarg[0].bstrVal;
CComVariant retVal = (::PathFileExists(strStore) ? true : false);
if(pVarResult != NULL)
{
retVal.Detach(pVarResult);
}
return S_OK;
}
示例6: getComVariant
void ActiveXBrowserHost::getComVariant(VARIANT *dest, const FB::variant &var)
{
CComVariant outVar;
::VariantInit(dest);
const ComVariantBuilderMap& builderMap = getComVariantBuilderMap();
const std::type_info& type = var.get_type();
ComVariantBuilderMap::const_iterator it = builderMap.find(&type);
if (it == builderMap.end()) {
// unhandled type :(
return;
}
outVar = (it->second)(FB::ptr_cast<ActiveXBrowserHost>(shared_ptr()), var);
outVar.Detach(dest);
}
示例7: fireOnBeforeRequest
//----------------------------------------------------------------------------
//
HRESULT CAnchoRuntime::fireOnBeforeRequest(const std::wstring &aUrl, const std::wstring &aMethod, const CAnchoRuntime::FrameRecord *aFrameRecord, /*out*/ BeforeRequestInfo &aOutInfo)
{
CComPtr<ComSimpleJSObject> info;
IF_FAILED_RET(SimpleJSObject::createInstance(info));
fillRequestInfo(*info, aUrl, aMethod, aFrameRecord);
CComPtr<ComSimpleJSArray> argArray;
IF_FAILED_RET(SimpleJSArray::createInstance(argArray));
argArray->push_back(CComVariant(info.p));
CComVariant result;
m_pAnchoService->invokeEventObjectInAllExtensions(CComBSTR(L"webRequest.onBeforeRequest"), argArray.p, &result);
if (result.vt & VT_ARRAY) {
CComSafeArray<VARIANT> arr;
arr.Attach(result.parray);
//contained data already managed by CComSafeArray
VARIANT tmp = {0}; HRESULT hr = result.Detach(&tmp);
BEGIN_TRY_BLOCK
aOutInfo.cancel = false;
for (ULONG i = 0; i < arr.GetCount(); ++i) {
Ancho::Utils::JSObjectWrapperConst item = Ancho::Utils::JSValueWrapperConst(arr.GetAt(i)).toObject();
Ancho::Utils::JSValueWrapperConst cancel = item[L"cancel"];
if (!cancel.isNull()) {
aOutInfo.cancel = aOutInfo.cancel || cancel.toBool();
}
Ancho::Utils::JSValueWrapperConst redirectUrl = item[L"redirectUrl"];
if (!redirectUrl.isNull()) {
aOutInfo.redirect = true;
aOutInfo.newUrl = redirectUrl.toString();
}
}
END_TRY_BLOCK_CATCH_TO_HRESULT
}
示例8: Invoke
STDMETHODIMP CBDictionary::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
if((dispIdMember & 0xff000000) != 0x65000000)
return CBDispatch<IVariantDictionary>::g_typeinfo.Invoke((IVariantDictionary*)this, dispIdMember, wFlags,
pDispParams, pVarResult, pExcepInfo, puArgErr);
dispIdMember &= 0xffffff;
CBLock l(&m_cs);
if(dispIdMember < (int)m_posArray.GetCount())
{
if((wFlags & (DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYPUTREF)) && pDispParams->cArgs == 1)
{
VARIANT* pvar = pDispParams->rgvarg;
while(pvar->vt == (VT_VARIANT | VT_BYREF))
pvar = pvar->pvarVal;
if(!(wFlags & DISPATCH_PROPERTYPUTREF) &&
(pvar->vt == VT_UNKNOWN || pvar->vt == VT_DISPATCH))
{
l.Unlock();
if(pvar->punkVal == NULL)
return DISP_E_UNKNOWNINTERFACE;
CBDispatchPtr pDisp;
CComVariant var;
HRESULT hr = pvar->punkVal->QueryInterface(&pDisp);
if(FAILED(hr))return hr;
hr = pDisp.GetProperty(0, &var);
if(FAILED(hr))return hr;
l.Lock();
if(dispIdMember < (int)m_posArray.GetCount())
{
var.Detach(&m_posArray[dispIdMember]->m_value);
return S_OK;
}else return DISP_E_MEMBERNOTFOUND;
}else return VariantCopyInd(&m_posArray[dispIdMember]->m_value, pvar);
}else if(pDispParams->cArgs == 0)
{
if(pVarResult != NULL)
return VariantCopy(pVarResult, &m_posArray[dispIdMember]->m_value);
return S_OK;
}
VARIANT *pvar = &m_posArray[dispIdMember]->m_value;
if(pvar->vt == VT_UNKNOWN || pvar->vt == VT_DISPATCH)
{
CBDispatchPtr pDisp;
HRESULT hr = pvar->punkVal->QueryInterface(&pDisp);
if(FAILED(hr))
return DISP_E_BADPARAMCOUNT;
l.Unlock();
return pDisp->Invoke(0, riid, lcid, wFlags, pDispParams,
pVarResult, pExcepInfo, puArgErr);
}
return DISP_E_BADPARAMCOUNT;
}else return DISP_E_MEMBERNOTFOUND;
return S_OK;
}
示例9: PCSoftRun
HRESULT CMainDlg::PCSoftRun(DISPID dispIdMember, DISPPARAMS *pDispParams, VARIANT *pVarResult)
{
CComVariant retVal;
if(pDispParams->rgvarg[0].bstrVal == NULL || pDispParams->rgvarg[0].bstrVal[0] == L'\0')
{
retVal = false;
}
else
{
ShowWindow(FALSE);
CString strOld;
CString strNew;
GetRegExtInfo(strOld);
CString strStore;
BKSafeConfig::GetStoreDir(strStore);
SHCreateDirectory(NULL, strStore);
strStore = _PathAddBackslash(strStore) + pDispParams->rgvarg[0].bstrVal;
CString strCmd;
strCmd = strStore;
CreateProcessSyn(strCmd);
GetRegExtInfo(strNew);
if (strOld != strNew)
{
CBkSafeMsgBox2 msgbox;
msgbox.AddButton(L"是", IDOK);
msgbox.AddButton(L"否", IDCANCEL);
CString strMsg;
strMsg.Format(L"软件安装完成,是否立即打开文件“%s”", m_strFileName);
UINT nRet = msgbox.ShowMutlLineMsg(strMsg,
NULL, MB_BK_CUSTOM_BUTTON|MB_ICONQUESTION, NULL);
if(nRet == IDOK)
{
::ShellExecute(NULL, L"open", g_strCmd, L"", NULL, SW_SHOWNORMAL);
}
}
else
{
CBkSafeMsgBox2 msgbox;
msgbox.AddButton( TEXT("确定"), IDOK);
CString strMsg;
strMsg.Format(L"由于您已取消,将无法打开文件“%s”", m_strFileName);
msgbox.ShowMutlLineMsg( strMsg, NULL, MB_BK_CUSTOM_BUTTON | MB_ICONWARNING );
}
OnBkBtnClose();
//::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
retVal = true;
}
if(pVarResult != NULL)
{
retVal.Detach(pVarResult);
}
return S_OK;
}
示例10: PCSoftStartDown
HRESULT CMainDlg::PCSoftStartDown(DISPID dispIdMember, DISPPARAMS *pDispParams, VARIANT *pVarResult)
{
CComVariant retVal = false;
do
{
LONG id = safe_atol(pDispParams->rgvarg[4].bstrVal);
if(id == 0)
{
break;
}
//
// 若文件已存在,则直接返回
//
CString strStore;
BKSafeConfig::GetStoreDir(strStore);
SHCreateDirectory(NULL, strStore);
strStore = _PathAddBackslash(strStore) + pDispParams->rgvarg[1].bstrVal;
if(::PathFileExists(strStore))
{
retVal = true;
break;
}
CriticalSectionScoped locker(m_csPhoneNess);
// 若任务已经存在,则直接返回
{
Id2PhoneSoftIter itSoft = m_id2PhoneSoft.Lookup(id);
if(itSoft != NULL)
{
retVal = false;
break;
}
}
IDTManager *pDTMgr = GetDTMgrForPhone();
if(pDTMgr != NULL)
{
int curPos = 0;
CString strUrl = pDispParams->rgvarg[3].bstrVal;
CString token = strUrl.Tokenize(L" ", curPos);
if(!token.IsEmpty())
{
CAtlArray<CString> *pUrlArray = new CAtlArray<CString>();
do
{
pUrlArray->Add(token);
token = strUrl.Tokenize(L" ", curPos);
}
while(!token.IsEmpty());
PhoneSoft ps;
ps.speed = 0;
ps.recved = 0;
ps.state = PDS_INIT;
ps.idDown = pDTMgr->NewTask(pUrlArray, pDispParams->rgvarg[2].bstrVal, strStore);
m_id2PhoneSoft[id] = ps;
m_dt2Id[ps.idDown] = id;
retVal = true;
}
}
}
while(FALSE);
if(pVarResult != NULL)
{
retVal.Detach(pVarResult);
}
return S_OK;
}