本文整理汇总了C++中CComBSTR::Attach方法的典型用法代码示例。如果您正苦于以下问题:C++ CComBSTR::Attach方法的具体用法?C++ CComBSTR::Attach怎么用?C++ CComBSTR::Attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComBSTR
的用法示例。
在下文中一共展示了CComBSTR::Attach方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UacChangePwd
extern "C" int UacChangePwd (char *lpszVolume, Password *oldPassword, int old_pkcs5, BOOL truecryptMode, Password *newPassword, int pkcs5, int wipePassCount, HWND hwndDlg)
{
CComPtr<ITrueCryptMainCom> tc;
int r;
if (ComGetInstance (hwndDlg, &tc))
{
WaitCursor ();
CComBSTR volumeBstr;
BSTR bstr = A2WBSTR(lpszVolume);
if (bstr)
{
volumeBstr.Attach (bstr);
r = tc->ChangePasswordEx2 (volumeBstr, oldPassword, old_pkcs5, truecryptMode, newPassword, pkcs5, wipePassCount, (LONG_PTR) hwndDlg);
}
else
r = ERR_OUTOFMEMORY;
NormalCursor ();
}
else
r = -1;
return r;
}
示例2: UacRestoreVolumeHeader
extern "C" int UacRestoreVolumeHeader (HWND hwndDlg, wchar_t *lpszVolume)
{
CComPtr<ITrueCryptMainCom> tc;
int r;
CoInitialize (NULL);
if (ComGetInstance (hwndDlg, &tc))
{
CComBSTR volumeBstr;
BSTR bstr = W2BSTR(lpszVolume);
if (bstr)
{
volumeBstr.Attach (bstr);
r = tc->RestoreVolumeHeader ((LONG_PTR) hwndDlg, volumeBstr);
}
else
r = ERR_OUTOFMEMORY;
}
else
r = -1;
CoUninitialize ();
return r;
}
示例3: UacBackupVolumeHeader
extern "C" int UacBackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, char *lpszVolume)
{
CComPtr<ITrueCryptMainCom> tc;
int r;
CoInitialize (NULL);
if (ComGetInstance (hwndDlg, &tc))
{
CComBSTR volumeBstr;
BSTR bstr = A2WBSTR(lpszVolume);
if (bstr)
{
volumeBstr.Attach (bstr);
r = tc->BackupVolumeHeader ((LONG_PTR) hwndDlg, bRequireConfirmation, volumeBstr);
}
else
r = ERR_OUTOFMEMORY;
}
else
r = -1;
CoUninitialize ();
return r;
}
示例4: OnMessageSend
LRESULT WebSocketClientHost::OnMessageSend(UINT nMsg, WPARAM wParam, LPARAM lParam, _Inout_ BOOL& /*bHandled*/)
{
// Take ownership of the string
CComBSTR message;
message.Attach(reinterpret_cast<BSTR>(wParam));
// Send the message to the server
CString messageData(message);
this->SendMessageToWebSocket(messageData);
return 0;
}
示例5: GetTabItemText
Handle<Value> CSkinTab::V8GetTabItemText(const Arguments& args)
{
HandleScope handleScope;
LONG arg0 = Handle<Integer>::Cast(args[0])->Int32Value();
BSTR ret = GetTabItemText(arg0);
CComBSTR bstrRet;
bstrRet.Attach(ret);
CComVariant varRet = bstrRet;
Handle<Value> result = VariantToValue(varRet);
return handleScope.Close(result);
}
示例6: StripCarriageReturns
// Visual Studio API returns offsets without considering \r symbol, however Emmet engine does consider it. In
// order to unify offsets generation we'll have to remove all \r symbols using this function from strings that
// we are returning to the Emmet engine.
void StripCarriageReturns(BSTR str, BSTR* pOut)
{
CComBSTR source;
source.Attach(str);
int len = source.Length();
CAutoPtr<WCHAR> destination(new WCHAR[len + 1]);
int destIndex = 0;
for (int srcIndex = 0; srcIndex < len; srcIndex++)
{
WCHAR ch = source[srcIndex];
if (ch != L'\r')
destination[destIndex++] = ch;
}
destination[destIndex] = 0;
*pOut = SysAllocString(destination);
}
示例7: ReportXmlError
HRESULT ReportXmlError(
const char *pszName,
IXMLDOMParseError *pXMLError
)
{
long line;
long linePos;
long errorCode = E_FAIL;
CComBSTR bReason;
BSTR bstr;
HRESULT hr;
hr = pXMLError->get_line(&line);
if (FAILED(hr))
{
line = 0;
}
hr = pXMLError->get_linepos(&linePos);
if (FAILED(hr))
{
linePos = 0;
}
hr = pXMLError->get_errorCode(&errorCode);
if (FAILED(hr))
{
errorCode = E_FAIL;
}
hr = pXMLError->get_reason(&bstr);
if (SUCCEEDED(hr))
{
bReason.Attach(bstr);
}
fprintf(stderr,
"ERROR: failed to load %s, line %lu, line position %lu, errorCode %08x\nERROR: reason: %S\n",
pszName, line, linePos, errorCode, (PWCHAR)bReason);
return errorCode;
}
示例8: OnSetMessageHwnd
LRESULT WebSocketClientHost::OnSetMessageHwnd(UINT nMsg, WPARAM wParam, LPARAM lParam, _Inout_ BOOL& /*bHandled*/)
{
// Take ownership of the string
CComBSTR idBstr;
idBstr.Attach(reinterpret_cast<BSTR>(wParam));
HWND hwnd = reinterpret_cast<HWND>(lParam);
// Store the engine hwnd
m_threadEngineHosts[idBstr] = hwnd;
// Fire any queued messages
if (m_threadEngineMessageQueue.find(idBstr) != m_threadEngineMessageQueue.end())
{
for (auto& i : m_threadEngineMessageQueue[idBstr])
{
this->SendMessageToThreadEngine(std::move(i), /*shouldCreateEngine=*/ false);
}
m_threadEngineMessageQueue[idBstr].clear();
}
return 0;
}
示例9: OnInitDialog
BOOL CPageMesTemplates::OnInitDialog()
{
CMcSettingsPage::OnInitDialog();
m_ShowAuto = GetOptionInt(IDS_OFSMESSENGER,IDS_SEND_MESSAGE_TEMPLATE_AUTO,1);
DWORD dwStyle = m_TemplateList.GetExtendedStyle();
dwStyle |= LVS_EX_FULLROWSELECT;
m_TemplateList.SetExtendedStyle(dwStyle);
m_TemplateList.InsertColumn(0,GetString(IDS_TEMPLATE_NAME),LVCFMT_LEFT,150);
m_TemplateList.InsertColumn(1,GetString(IDS_TEMPLATE_TEXT),LVCFMT_LEFT,300);
if(m_UserId)
{
// Step 1. Load Color Settings [8/24/2002]
CString strSection;
strSection.Format(_T("%s\\%s\\%d"),GetString(IDS_INFO),m_UserRole,m_UserId);
CString strMessageTemplateXML = GetRegFileText(strSection,GetString(IDS_MESSAGE_TEMPLATES_REG));
if(strMessageTemplateXML.IsEmpty())
strMessageTemplateXML = GetString(IDS_DEFAULT_MES_TEMPLATE_XML);
CComPtr<IXMLDOMDocument> pMTDoc = NULL;
pMTDoc.CoCreateInstance(CLSID_DOMDocument40,NULL,CLSCTX_INPROC_SERVER);
if(pMTDoc)
{
CComBSTR bsXML;
bsXML.Attach(strMessageTemplateXML.AllocSysString());
VARIANT_BOOL varLoad = VARIANT_FALSE;
pMTDoc->loadXML(bsXML,&varLoad);
if(varLoad==VARIANT_FALSE)
{
bsXML.Empty();
strMessageTemplateXML = GetString(IDS_DEFAULT_MES_TEMPLATE_XML);
bsXML.Attach(strMessageTemplateXML.AllocSysString());
pMTDoc->loadXML(bsXML,&varLoad);
}
if(varLoad==VARIANT_TRUE)
{
CComPtr<IXMLDOMNodeList> pTemplatesList = NULL;
pMTDoc->selectNodes(CComBSTR(L"message_templates/mt"),&pTemplatesList);
if(pTemplatesList!=NULL)
{
USES_CONVERSION;
long ListLength = 0;
pTemplatesList->get_length(&ListLength);
for(int Index=0;Index<ListLength;Index++)
{
CComBSTR bsName, bsText;
CComPtr<IXMLDOMNode> pStubNode = NULL;
pTemplatesList->get_item(Index,&pStubNode);
GetTextByPath(pStubNode, CComBSTR(L"name"),&bsName);
GetTextByPath(pStubNode, CComBSTR(L"text"),&bsText);
m_TemplateList.InsertItem(Index,W2CT(bsName));
m_TemplateList.SetItemText(Index,1,W2CT(bsText));
}
}
}
}
}
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}