本文整理汇总了C++中CComQIPtr::CoCreateInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ CComQIPtr::CoCreateInstance方法的具体用法?C++ CComQIPtr::CoCreateInstance怎么用?C++ CComQIPtr::CoCreateInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComQIPtr
的用法示例。
在下文中一共展示了CComQIPtr::CoCreateInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrepareResult
bool CSelectCoordSysActionDlg::PrepareResult()
{
// Selektierten Eintrag holen
HTREEITEM hItem = m_tvCoordSystems.GetSelectedItem();
if (NULL == hItem || m_tvCoordSystems.ItemHasChildren (hItem))
return false; // nur Childs behandeln
CCoordSystemItem *pItemData = (CCoordSystemItem *)m_tvCoordSystems.GetItemData (hItem);
if (NULL == pItemData)
return false;
// Koordinatensystem am Parent setzen
CString strTcfName = pItemData->GetTcfName();
COM_TRY {
CComQIPtr<ITRiASCS, &IID_ITRiASCS> CS;
THROW_FAILED_HRESULT(CS.CoCreateInstance(CLSID_TRIASCS));
THROW_FAILED_HRESULT(CS -> LoadFromFile(CComBSTR(strTcfName)));
m_CS = CS; // store result coordsystem
} COM_CATCH_OP_RETURN(CantLoadCS(strTcfName), false);
return true;
}
示例2: elementDone
void GenericDocument::elementDone(IDOMElement* element)
{
BSTR btagName;
element->get_tagName(&btagName);
_bstr_t tagName = _bstr_t(btagName);
if (!wcsicmp(tagName, L"style"))
{
CComQIPtr<IDOMNode> child;
element->get_firstChild(&child);
CComQIPtr<IDOMText> text = child;
if (text)
{
BSTR btextdata;
text->get_data(&btextdata);
_bstr_t textdata = _bstr_t(btextdata, false);
CComQIPtr<IDOMCSSStyleSheet> stylesheet;
stylesheet.CoCreateInstance(CLSID_DOMCSSStyleSheet);
CComQIPtr<IDocumentStyle> documentStyle = GetControllingUnknown();
if (documentStyle)
{
CComQIPtr<IStyleSheetList> stylesheetList;
documentStyle->get_styleSheets(&stylesheetList);
stylesheetList->append(stylesheet);
CComQIPtr<IHTMLStyleSheet> htmlstylesheet = stylesheet;
htmlstylesheet->set_cssText(textdata); // The stylesheet will parse the text
}
}
}
}
示例3: EnableActiveDesktop
static
HRESULT EnableActiveDesktop(bool enable)
{
CoInitialize(NULL);
CComQIPtr<IActiveDesktop, &IID_IActiveDesktop> pIActiveDesktop;
HRESULT hr;
hr = pIActiveDesktop.CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER);
if (!SUCCEEDED(hr))
return hr;
COMPONENTSOPT opt;
opt.dwSize = sizeof(opt);
opt.fActiveDesktop = opt.fEnableComponents = enable;
hr = pIActiveDesktop->SetDesktopItemOptions(&opt, 0);
if (!SUCCEEDED(hr))
{
CoUninitialize();
return hr;
}
hr = pIActiveDesktop->ApplyChanges(AD_APPLY_REFRESH);
CoUninitialize();
return hr;
}
示例4: ShowViews
STDMETHODIMP CWebSite::ShowViews()
{
CComQIPtr<IWebEditorFrame> frame;
gApp->get_frame(&frame);
CComQIPtr<IUIContextManager> uiManager;
gApp->get_uiManager(&uiManager);
{
CComQIPtr<IUIMDIChild> child;
child.CoCreateInstance(CLSID_UIMDIChild);
// Files
{
CComQIPtr<ISiteFilesView> filesView;
filesView.CoCreateInstance(CLSID_SiteFilesView);
filesView->Create(uiManager, L"Files", (IID*)&CLSID_SiteFilesView, NULL);
filesView->put_webSiteDocument(this);
child->AddView(filesView, NULL);
}
// Links
{
CComQIPtr<ISiteLinksView> linksView;
linksView.CoCreateInstance(CLSID_SiteLinksView);
linksView->Create(uiManager, L"Links", (IID*)&CLSID_SiteFilesView, NULL);
linksView->put_document(this);
child->AddView(linksView, NULL);
}
// FTP
{
CComQIPtr<ISiteFTPView> ftpView;
ftpView.CoCreateInstance(CLSID_SiteFTPView);
ftpView->Create(uiManager, L"FTP", (IID*)&CLSID_SiteFilesView, NULL);
ftpView->put_document(this);
child->AddView(ftpView, NULL);
}
child->CreateMDIChild(frame, NULL);
child.Detach(); // Keep it open
}
return S_OK;
}
示例5: sMsg
void CUse3Dlg::OnBnClickedButton6() // 智能指针的释放
{
::CoInitialize( NULL ); // 如果在这里进行 COM 初始化,要注意智能指针的释放
CComQIPtr < IFun, &IID_IFun > spFun;
HRESULT hr = spFun.CoCreateInstance( CLSID_Fun );
ASSERT( SUCCEEDED( hr ) );
// 为了简单起见,不再使用 if 判断 HRESULT 了。IFun::Add() 也没有调用
CComBSTR s1( "Hello" ), s2( " world" ), s3;
hr = spFun->Cat( s1, s2, &s3 );
ASSERT( SUCCEEDED( hr ) );
CString sMsg( s3 );
AfxMessageBox( sMsg );
// spFun->Release(); // 大错特错!!!
spFun.Release(); // 正解
::CoUninitialize();
}
示例6: OnLButtonDown
LRESULT CSQLTableWnd::OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
POINT point;
point.x = (short)LOWORD(lParam);
point.y = (short)HIWORD(lParam);
if (!(wParam & MK_SHIFT))
{
for (int i = 0; i < m_columns.GetSize(); i++)
{
m_columns[i]->m_bSelected = false;
}
}
long index = point.y/16;
if (index >= 0 && index < m_table->Columns->Count)
{
m_columns[index]->m_bSelected = true;
Invalidate();
UpdateWindow();
CComQIPtr<ILDOMDocument> document;
document.CoCreateInstance(CLSID_LDOMDocument);
VARIANT_BOOL success;
document->loadXML(L"<columns/>", &success);
CComQIPtr<ILDOMElement> documentElement;
document->get_documentElement(&documentElement);
documentElement->setAttribute(L"fromtable", m_table->Name);
for (long i = 0; i < m_columns.GetSize(); i++)
{
if (m_columns[i]->m_bSelected)
{
CComQIPtr<ILDOMElement> element;
document->createElement(L"column", &element);
element->setAttribute(L"name", m_table->Columns->Item[_variant_t(index)]->Name);
documentElement->appendChild(element, NULL);
}
}
BSTR text;
document->saveXML(NULL, &text);
int len = SysStringLen(text);
HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, (len+1)*2);
if (hData)
{
WCHAR* p = (WCHAR*)GlobalLock(hData);
CopyMemory(p, text, (len+1)*2);
GlobalUnlock(hData);
CMyDropSource* dropSource = new CMyDropSource;
CMyDataObject* dataObject = new CMyDataObject;
STGMEDIUM stg = {0};
stg.tymed = TYMED_HGLOBAL;
stg.hGlobal = hData;
stg.pUnkForRelease = NULL;
FORMATETC etc = {0};
etc.cfFormat = CF_UNICODETEXT;//CF_UNICODETEXT;//49285;//RegisterClipboardFormat(CFSTR_SHELLURL);//CF_TEXT;
etc.tymed = TYMED_HGLOBAL;
etc.ptd = NULL;
etc.dwAspect = DVASPECT_CONTENT;
etc.lindex = -1;
dataObject->SetData(&etc, &stg, TRUE);
DWORD dropEffect = 0;
HRESULT hr = ::DoDragDrop(dataObject, dropSource, DROPEFFECT_LINK | DROPEFFECT_COPY | DROPEFFECT_MOVE, &dropEffect);
if (hr == DRAGDROP_S_DROP)
{
if (dropEffect/* & DROPEFFECT_MOVE*/)
{
}
}
GlobalFree(hData);
// delete dataObject;
// delete dropSource;
#if 0
COleDataSource source;
source.CacheGlobalData(CF_HDROP, hData, NULL);
if (source.DoDragDrop(DROPEFFECT_COPY | DROPEFFECT_MOVE, NULL, NULL) == DROPEFFECT_COPY)
{
}
source.Empty();
#endif
}
//.........这里部分代码省略.........
示例7: OnInitDialog
BOOL CSaveDlg::OnInitDialog()
{
CCmdUIDialog::OnInitDialog();
//m_anim.Open(IDR_AVI_FILECOPY);
//m_anim.Play(0, -1, -1);
CString str, in = m_in, out = m_out;
if(in.GetLength() > 60) in = in.Left(17) + _T("..") + in.Right(43);
if(out.GetLength() > 60) out = out.Left(17) + _T("..") + out.Right(43);
str.Format(_T("%s\r\n%s"), in, out);
m_fromto.SetWindowText(str);
m_progress.SetRange(0, 100);
if(FAILED(pGB.CoCreateInstance(CLSID_FilterGraph)) || !(pMC = pGB) || !(pME = pGB) || !(pMS = pGB)
|| FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0)))
{
m_report.SetWindowText(_T("Error"));
return FALSE;
}
HRESULT hr;
CStringW fnw = m_in;
CComPtr<IFileSourceFilter> pReader;
if(!pReader && m_in.Mid(m_in.ReverseFind('.')+1).MakeLower() == _T("cda"))
{
hr = S_OK;
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)new CCDDAReader(NULL, &hr);
if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
pReader.Release();
}
if(!pReader)
{
hr = S_OK;
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)new CCDXAReader(NULL, &hr);
if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
pReader.Release();
}
if(!pReader /*&& ext == _T("ifo")*/)
{
hr = S_OK;
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)new CVTSReader(NULL, &hr);
if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
pReader.Release();
else
{
CPath pout(m_out);
pout.RenameExtension(_T(".ifo"));
CopyFile(m_in, pout, FALSE);
}
}
if(!pReader)
{
hr = S_OK;
CComPtr<IUnknown> pUnk;
pUnk.CoCreateInstance(CLSID_AsyncReader);
if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
pReader.Release();
}
if(!pReader)
{
hr = S_OK;
CComPtr<IUnknown> pUnk;
pUnk.CoCreateInstance(CLSID_URLReader);
if(CComQIPtr<IBaseFilter> pSrc = pUnk) // url reader has to be in the graph to load the file
{
pGB->AddFilter(pSrc, fnw);
if(FAILED(hr) || !(pReader = pUnk) || FAILED(hr = pReader->Load(fnw, NULL)))
{
pReader.Release();
pGB->RemoveFilter(pSrc);
}
}
}
CComQIPtr<IBaseFilter> pSrc = pReader;
if(FAILED(pGB->AddFilter(pSrc, fnw)))
{
m_report.SetWindowText(_T("Sorry, can't save this file, press cancel"));
return FALSE;
}
CComQIPtr<IBaseFilter> pMid = new CStreamDriveThruFilter(NULL, &hr);
if(FAILED(pGB->AddFilter(pMid, L"StreamDriveThru")))
{
m_report.SetWindowText(_T("Error"));
return FALSE;
}
CComQIPtr<IBaseFilter> pDst;
pDst.CoCreateInstance(CLSID_FileWriter);
CComQIPtr<IFileSinkFilter2> pFSF = pDst;
pFSF->SetFileName(CStringW(m_out), NULL);
//.........这里部分代码省略.........
示例8: OnInitDialog
BOOL CSaveDlg::OnInitDialog()
{
CCmdUIDialog::OnInitDialog();
AppSettings& s = AfxGetAppSettings();
CString str, in = m_name, out = m_out;
if (m_in.Find(_T("http://")) != -1 || m_in.Find(_T("ftp://")) != -1) {
m_anim.SendMessage(ACM_OPEN, (WPARAM)AfxGetInstanceHandle(), (LPARAM)IDR_AVI_WEB_FILECOPY);
} else {
m_anim.SendMessage(ACM_OPEN, (WPARAM)AfxGetInstanceHandle(), (LPARAM)IDR_AVI_FILECOPY);
}
m_anim.Play(0, (UINT)-1, (UINT)-1);
if (in.GetLength() > 60) {
in = in.Left(17) + _T("..") + in.Right(43);
}
if (out.GetLength() > 60) {
out = out.Left(17) + _T("..") + out.Right(43);
}
str.Format(_T("%s\r\n%s"), in, out);
m_fromto.SetWindowText(str);
m_progress.SetRange(0, 100);
if (OpenImageCheck(m_in) && s.strSnapShotExt != _T(".*")) {
OpenImageDIB(m_in, m_out, s.iThumbQuality, 0);
EndDialog(IDOK);
return TRUE;
}
if (FAILED(pGB.CoCreateInstance(CLSID_FilterGraph)) || !(pMC = pGB) || !(pME = pGB) || !(pMS = pGB)
|| FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0))) {
m_report.SetWindowText(_T("Error"));
return FALSE;
}
HRESULT hr;
CStringW fnw = m_in;
CComPtr<IFileSourceFilter> pReader;
if (!pReader && m_in.Mid(m_in.ReverseFind('.')+1).MakeLower() == _T("cda")) {
hr = S_OK;
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDDAReader(NULL, &hr);
if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
pReader.Release();
}
}
if (!pReader) {
hr = S_OK;
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDXAReader(NULL, &hr);
if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
pReader.Release();
}
}
if (!pReader /*&& ext == _T("ifo")*/) {
hr = S_OK;
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CVTSReader(NULL, &hr);
if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
pReader.Release();
} else {
CPath pout(m_out);
pout.RenameExtension(_T(".ifo"));
CopyFile(m_in, pout, FALSE);
}
}
if (!pReader) {
hr = S_OK;
CComPtr<IUnknown> pUnk;
hr = pUnk.CoCreateInstance(CLSID_AsyncReader);
if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
pReader.Release();
}
}
if (!pReader) {
hr = S_OK;
CComPtr<IUnknown> pUnk;
hr = pUnk.CoCreateInstance(CLSID_URLReader);
if (CComQIPtr<IBaseFilter> pSrc = pUnk) {
hr = pGB->AddFilter(pSrc, fnw);
if (FAILED(hr) || !(pReader = pUnk) || FAILED(hr = pReader->Load(fnw, NULL))) {
pReader.Release();
pGB->RemoveFilter(pSrc);
}
}
}
//.........这里部分代码省略.........
示例9: InitFileCopy
HRESULT CSaveTaskDlg::InitFileCopy()
{
AppSettings& s = AfxGetAppSettings();
if (OpenImageCheck(m_in) && s.strSnapShotExt != _T(".*")) {
OpenImageDIB(m_in, m_out, s.iThumbQuality, 0);
return S_OK;
}
if (FAILED(pGB.CoCreateInstance(CLSID_FilterGraph)) || !(pMC = pGB) || !(pME = pGB) || !(pMS = pGB)) {
SetFooterIcon(MAKEINTRESOURCE(IDI_ERROR));
SetFooterText(ResStr(IDS_AG_ERROR));
return S_FALSE;
}
HRESULT hr;
CStringW fnw = m_in;
CComPtr<IFileSourceFilter> pReader;
if (!pReader && m_in.Mid(m_in.ReverseFind('.')+1).MakeLower() == _T("cda")) {
hr = S_OK;
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDDAReader(NULL, &hr);
if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
pReader.Release();
}
}
if (!pReader) {
hr = S_OK;
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDXAReader(NULL, &hr);
if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
pReader.Release();
}
}
if (!pReader ) {
hr = S_OK;
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CVTSReader(NULL, &hr);
if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
pReader.Release();
} else {
CPath pout(m_out);
pout.RenameExtension(_T(".ifo"));
CopyFile(m_in, pout, FALSE);
}
}
if (!pReader) {
hr = S_OK;
CComPtr<IUnknown> pUnk;
pUnk.CoCreateInstance(CLSID_AsyncReader);
if (!(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
pReader.Release();
}
}
if (!pReader) {
hr = S_OK;
CComPtr<IUnknown> pUnk;
pUnk.CoCreateInstance(CLSID_URLReader);
if (CComQIPtr<IBaseFilter> pSrc = pUnk) {
pGB->AddFilter(pSrc, fnw);
if (!(pReader = pUnk) || FAILED(hr = pReader->Load(fnw, NULL))) {
pReader.Release();
pGB->RemoveFilter(pSrc);
}
}
}
CComQIPtr<IBaseFilter> pSrc = pReader;
if (FAILED(pGB->AddFilter(pSrc, fnw))) {
SetFooterIcon(MAKEINTRESOURCE(IDI_ERROR));
SetFooterText(_T("Sorry, can't save this file, press Cancel"));
return S_FALSE;
}
CComQIPtr<IBaseFilter> pMid = DNew CStreamDriveThruFilter(NULL, &hr);
if (FAILED(pGB->AddFilter(pMid, L"StreamDriveThru"))) {
SetFooterIcon(MAKEINTRESOURCE(IDI_ERROR));
SetFooterText(ResStr(IDS_AG_ERROR));
return S_FALSE;
}
CComQIPtr<IBaseFilter> pDst;
pDst.CoCreateInstance(CLSID_FileWriter);
CComQIPtr<IFileSinkFilter2> pFSF = pDst;
pFSF->SetFileName(CStringW(m_out), NULL);
pFSF->SetMode(AM_FILE_OVERWRITE);
if (FAILED(pGB->AddFilter(pDst, L"File Writer"))) {
//.........这里部分代码省略.........
示例10: OnFileNew
LRESULT CPageDesignerApp::OnFileNew(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
CNewDocumentDlg dlg;
dlg.m_numPages = 1;
dlg.m_pageWidth = ConvertSpecifiedValueToUserUnit(UNIT_PT, 612);
dlg.m_pageHeight = ConvertSpecifiedValueToUserUnit(UNIT_PT, 792);
dlg.m_marginLeft = ConvertSpecifiedValueToUserUnit(UNIT_PT, 36);
dlg.m_marginRight = ConvertSpecifiedValueToUserUnit(UNIT_PT, 36);
dlg.m_marginTop = ConvertSpecifiedValueToUserUnit(UNIT_PT, 36);
dlg.m_marginBottom = ConvertSpecifiedValueToUserUnit(UNIT_PT, 36);
dlg.m_columnNumber = 1;
dlg.m_columnGutter = ConvertSpecifiedValueToUserUnit(UNIT_PT, 12);
dlg.m_facingPages = TRUE;
if (dlg.DoModal(GetMainHwnd(), NULL) == IDOK)
{
CComObject<CPDDocument>* pDocument;
CComObject<CPDDocument>::CreateInstance(&pDocument);
if (pDocument)
{
pDocument->AddRef();
pDocument->m_pageWidth = dlg.m_pageWidth;
pDocument->m_pageHeight = dlg.m_pageHeight;
pDocument->m_marginTop = dlg.m_marginTop;
pDocument->m_marginBottom = dlg.m_marginBottom;
pDocument->m_marginInside = dlg.m_marginLeft;
pDocument->m_marginOutside = dlg.m_marginRight;
pDocument->m_columnNumber = dlg.m_columnNumber;
pDocument->m_columnGutter = dlg.m_columnGutter;
pDocument->m_facingPages = dlg.m_facingPages? VARIANT_TRUE: VARIANT_FALSE;
WCHAR str[256];
swprintf(str, L"Untitled%d.pddoc", ++m_nextDocumentIndex);
pDocument->m_fileTitle = str;
pDocument->NewDocument(); // Init (?)
pDocument->CreatePages(dlg.m_numPages);
pDocument->ShowViews();
// CComQIPtr<IUIManager> uiManager = m_frame;
// CComQIPtr<IPDDocument> document = pDocument;
// CComPtr<IUnknown> _this;
// QueryInterface(IID_IUnknown, (void**)&_this);
//uiManager->ActivateObject(GetUnknown(), document);
}
}
#if 0
HINSTANCE hLib = LoadLibrary("C:\\mmsx\\mmstudioplugins\\DOMCOREMOD.dll");
if (hLib)
{
HTMLModalDialogProc HTMLModalDialog = (HTMLModalDialogProc)GetProcAddress(hLib, "HTMLModalDialog");
if (HTMLModalDialog)
{
CComQIPtr<IDOMDocument> xmldoc;
xmldoc.CoCreateInstance(CLSID_LDocument);
xmldoc->put_async(VARIANT_FALSE);
VARIANT_BOOL success;
xmldoc->loadXML(L"<newdocument/>", &success);
CComQIPtr<IDOMElement> element;
xmldoc->get_documentElement(&element);
WCHAR buf[64];
swprintf(buf, L"%d", 1);
element->setAttribute(L"pagesnum", buf);
swprintf(buf, L"%d", 1);
element->setAttribute(L"columnsnum", buf);
swprintf(buf, L"%dpt", 1);
element->setAttribute(L"columnsgutter", buf);
_variant_t arg = (IDispatch*)element.p;
_variant_t result;
HTMLModalDialog(GetMainHwnd(), L"C:\\MMStudio\\pd_newdocument.html", &arg, L"", &result);
CComObject<CPDDocument>* pDocument;
CComObject<CPDDocument>::CreateInstance(&pDocument);
if (pDocument)
{
pDocument->AddRef();
pDocument->NewDocument(); // Init (?)
pDocument->m_pageWidth = 200;
pDocument->m_pageHeight = 400;
//.........这里部分代码省略.........
示例11: UpdateOutLinks
void CSiteFile::UpdateOutLinks()
{
try
{
WCHAR sql[256];
swprintf(sql, L"DELETE FROM links WHERE file_id = %d", m_dbid);
_variant_t va;
m_pWebSite->m_siteDataConnection->Execute(sql, &va, ADODB::adCmdText);
}
catch (_com_error &e)
{
DbError(e);
}
TCHAR ext[_MAX_EXT];
_splitpath(m_wfd.cFileName, NULL, NULL, NULL, ext);
if (!stricmp(ext, ".htm") ||
!stricmp(ext, ".html") ||
!stricmp(ext, ".asp") ||
!stricmp(ext, ".svg"))
{
CComQIPtr<IDOMDocumentContainer> documentcnt;
documentcnt.CoCreateInstance(CLSID_DOMDocumentContainer);
CSiteDir* pDir = (CSiteDir*)m_parent;
CUString pathName = GetFullPathName();
VARIANT_BOOL bsuccess;
documentcnt->load(_bstr_t(pathName), &bsuccess);
if (bsuccess)
{
CComQIPtr<IDOMDocument> document;
documentcnt->get_document(&document);
if (document != NULL)
{
{ // Links
CComQIPtr<IDOMElement> documentElement;
document->get_documentElement(&documentElement);
CComQIPtr<IMMSXHTMLDocument> htmldocument;
CComQIPtr<ISVGDocument> svgdocument;
CArray<IDOMElement*,IDOMElement*> elements;
if (htmldocument = document)
{
CollectElementTags(L"a", elements, documentElement);
}
else if (svgdocument = document)
{
CollectElementTags(L"a", elements, documentElement);
}
for (int i = 0; i < elements.GetSize(); i++)
{
IDOMElement* element = elements[i];
BSTR bhref;
if (htmldocument)
{
element->getAttribute(L"href", &bhref);
}
else if (svgdocument)
{
// TODO, use getAttributeNS
element->getAttribute(L"xlink:href", &bhref);
}
_bstr_t href = _bstr_t(bhref, false);
if (href.length())
{
char oldcwd[_MAX_PATH];
_getcwd(oldcwd, _MAX_PATH);
chdir(pDir->m_pathName);
char fullpath[_MAX_PATH];
_fullpath(fullpath, href, _MAX_PATH);
chdir(oldcwd);
CSiteFile* pHrefFile = (CSiteFile*)m_pWebSite->m_pRootDir->FindFilePathName(fullpath, 2);
if (pHrefFile)
{
try
{
WCHAR sql[256];
swprintf(sql, L"INSERT INTO links (file_id, out_link_id) VALUES ('%d', %d)", m_dbid, pHrefFile->m_dbid);
_variant_t va;
m_pWebSite->m_siteDataConnection->Execute(sql, &va, ADODB::adCmdText);
}
catch (_com_error &e)
{
DbError(e);
//.........这里部分代码省略.........
示例12: InsertGif
void CExRichEditWindowless::InsertGif(LONG gif)
{
CComQIPtr<IDynamicOleCom> spDyn;
HRESULT hr = spDyn.CoCreateInstance(STR_PROGID);
if(SUCCEEDED(hr))
{
LPOLEOBJECT lpOleObject = NULL;
HRESULT hr = spDyn->QueryInterface(IID_IOleObject, (void**)&lpOleObject);
IUnknownPtr lpUnk = lpOleObject;
hr = lpUnk->QueryInterface(IID_IOleObject, (LPVOID*)&lpOleObject);
if (lpOleObject == NULL)
throw(E_OUTOFMEMORY);
//hr = lpOleObject->SetClientSite( static_cast<IOleClientSite *>( this ) );
IViewObject2Ptr lpViewObject;// IViewObject for IOleObject above
hr = lpOleObject->QueryInterface(IID_IViewObject2, (LPVOID*)&lpViewObject);
if (hr != S_OK)
{
AtlThrow(hr);
}
IRichEditOle* pRichEditOle = GetIRichEditOle();
////获取RichEdit的OLEClientSite
IOleClientSitePtr lpClientSite;
hr = pRichEditOle->GetClientSite(&lpClientSite);
if (hr != S_OK)
{
AtlThrow(hr);
}
REOBJECT reobject;
ZeroMemory(&reobject,sizeof(REOBJECT));
reobject.cbStruct = sizeof(REOBJECT);
CLSID clsid;
hr = lpOleObject->GetUserClassID(&clsid);
if (hr != S_OK)
{
AtlThrow(hr);
}
reobject.clsid = clsid;
reobject.cp = -1;
//reobject.cp = REO_CP_SELECTION;
reobject.dvaspect = DVASPECT_CONTENT;//DVASPECT_OPAQUE;
reobject.poleobj = lpOleObject;
reobject.polesite = lpClientSite;
//reobject.pstg = lpStorage;
SIZEL sizel;
sizel.cx = sizel.cy = 0; // let richedit determine initial size
Image* img = (Image*)gif;
SIZEL sizeInPix = {img->GetWidth(), img->GetHeight()};
SIZEL sizeInHiMetric;
AtlPixelToHiMetric(&sizeInPix, &sizeInHiMetric);
reobject.sizel = sizeInHiMetric;
reobject.dwFlags = REO_BELOWBASELINE|REO_STATIC;//REO_RESIZABLE
CExRichEditData* pdata = new CExRichEditData;
pdata->m_dataType = GIF;
pdata->m_data = (void*)gif;
reobject.dwUser = (DWORD)pdata;//TODO 用户数据
lpOleObject->SetClientSite(lpClientSite);
hr = pRichEditOle->InsertObject(&reobject);
lpOleObject->SetExtent(DVASPECT_CONTENT, &sizeInHiMetric);
OleSetContainedObject(lpOleObject, TRUE);
lpOleObject->Release();
spDyn->SetHostWindow((LONG)hwndParent);
spDyn->InsertGif(gif);
}
}
示例13: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr;
// Initializes the COM library on the current thread and identifies the
// concurrency model as single-thread apartment (STA).
::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
/////////////////////////////////////////////////////////////////////////
// Create the ATLDllCOMServer.SimpleObject COM object using the
// #import directive and smart pointers.
//
CComQIPtr<ISimpleObject> spSimpleObj;
hr = spSimpleObj.CoCreateInstance(OLESTR(
"ATLDllCOMServer.SimpleObject"));
if (FAILED(hr))
{
_tprintf(_T(
"ISimpleObjectPtr.CoCreateInstance failed w/err 0x%08lx\n"
), hr);
return hr;
}
/////////////////////////////////////////////////////////////////////////
// Use sink object 1 (CATLSimpleSinkObject1) to set up the sink for the
// events of the source COM object.
//
_putts(_T("Create sink object 1"));
// Construct the sink object CATLSimpleSinkObject1 defined in
// ATLSimpleSinkObject.h
CATLSimpleSinkObject1* pSinkObj1 = new CATLSimpleSinkObject1();
// Make sure the COM object corresponding to pUnk implements
// IProvideClassInfo2 or IPersist*. Call this method to extract info
// about source type library if you specified only 2 parameters to
// IDispEventImpl.
hr = AtlGetObjectSourceInterface(spSimpleObj, &pSinkObj1->m_libid,
&pSinkObj1->m_iid, &pSinkObj1->m_wMajorVerNum,
&pSinkObj1->m_wMinorVerNum);
_ASSERTE(SUCCEEDED(hr));
// Connect the sink and source, spSimpleObj is the source COM object
hr = pSinkObj1->DispEventAdvise(spSimpleObj, &pSinkObj1->m_iid);
_ASSERTE(SUCCEEDED(hr));
// Invoke the source COM object
{
// Set FloatProperty which fires the event FloatPropertyChanging
_tprintf(_T("Set FloatProperty = %.2f\n"), 1.1f);
spSimpleObj->PutFloatProperty(1.1f);
float fProp = spSimpleObj->GetFloatProperty();
_tprintf(_T("Get FloatProperty = %.2f\n"), fProp);
}
// Disconnect from the source COM object if connected
if (pSinkObj1->m_dwEventCookie != 0xFEFEFEFE)
pSinkObj1->DispEventUnadvise(spSimpleObj, &pSinkObj1->m_iid);
// Destroy the sink object
delete pSinkObj1;
/////////////////////////////////////////////////////////////////////////
// Use sink object 2 (CATLSimpleSinkObject2) to set up the sink for the
// events of the source COM object.
//
_putts(_T("Create sink object 2"));
// Construct the sink object CATLSimpleSinkObject2 defined in
// ATLSimpleSinkObject.h
CATLSimpleSinkObject2* pSinkObj2 = new CATLSimpleSinkObject2();
// Connect the sink and source, m_spSrcObj is the source COM object
hr = pSinkObj2->DispEventAdvise(spSimpleObj);
_ASSERTE(SUCCEEDED(hr));
// Invoke the source COM object
{
// Set FloatProperty which fires the event FloatPropertyChanging
_tprintf(_T("Set FloatProperty = %.2f\n"), 1.2f);
spSimpleObj->PutFloatProperty(1.2f);
float fProp = spSimpleObj->GetFloatProperty();
_tprintf(_T("Get FloatProperty = %.2f\n"), fProp);
}
// Disconnect from source if connected
if (pSinkObj2->m_dwEventCookie != 0xFEFEFEFE)
pSinkObj2->DispEventUnadvise(spSimpleObj);
//.........这里部分代码省略.........
示例14: AllocateGenerator
/*---------------------------------------------------------------------------
Name: RdcGeneratorJob::AllocateGenerator
Allocate the resources necessary for signature generation.
This includes connecting to the RDC SDK, allocating buffers, and parameters
Arguments:
fileSize - used to compute RDC recursion depth.
requestedDepth - the preferred recursion depth, if 0, a default is calculated
----------------------------------------------------------------------------*/
DebugHresult RdcGeneratorJob::AllocateGenerator (
ULONGLONG fileSize,
ULONG requestedDepth )
{
DebugHresult hr = S_OK;
RDCAssert ( requestedDepth <= MSRDC_MAXIMUM_DEPTH );
RDCAssert ( !m_Failed );
m_Depth = 0;
BYTE *buffer = m_InputBuffer.AppendItems ( g_InputBufferSize );
if ( !buffer )
{
hr = E_OUTOFMEMORY;
}
if ( SUCCEEDED ( hr ) )
{
hr = m_RdcLibrary.CoCreateInstance ( __uuidof ( RdcLibrary ) );
}
if ( SUCCEEDED ( hr ) )
{
if ( requestedDepth == 0 )
{
hr = m_RdcLibrary->ComputeDefaultRecursionDepth ( fileSize, &m_Depth );
}
else
{
m_Depth = requestedDepth;
}
}
if ( SUCCEEDED ( hr ) )
{
if ( m_Depth == 0 )
{
m_Depth = 1;
}
if ( m_Depth > MSRDC_MAXIMUM_DEPTH )
{
m_Depth = MSRDC_MAXIMUM_DEPTH;
}
}
for ( ULONG i = 0; SUCCEEDED ( hr ) && i < m_Depth; ++i )
{
hr = m_RdcLibrary->CreateGeneratorParameters ( RDCGENTYPE_FilterMax, i + 1, &m_RdcGeneratorParameters[i] );
m_GeneratorParameters[i] = m_RdcGeneratorParameters[i];
if ( SUCCEEDED ( hr ) )
{
IRdcGeneratorFilterMaxParameters * q = 0;
if ( i == 0 )
{
hr = m_RdcGeneratorParameters[0].QueryInterface ( &q );
if ( SUCCEEDED ( hr ) )
{
hr = q->SetHashWindowSize ( m_HashWindowSize1 );
}
if ( SUCCEEDED ( hr ) )
{
hr = q->SetHorizonSize ( m_HorizonSize1 );
}
}
else
{
hr = m_RdcGeneratorParameters[i].QueryInterface ( &q );
if ( SUCCEEDED ( hr ) )
{
hr = q->SetHashWindowSize ( m_HashWindowSizeN );
}
if ( SUCCEEDED ( hr ) )
{
hr = q->SetHorizonSize ( m_HorizonSizeN );
}
}
if ( q )
{
q->Release();
}
}
}
if ( SUCCEEDED ( hr ) )
{
hr = m_RdcLibrary->CreateGenerator ( m_Depth, &m_GeneratorParameters[0], &m_RdcGenerator );
}
//.........这里部分代码省略.........
示例15: R_dataframe2dataset
SEXP R_dataframe2dataset(SEXP dtaframe, SEXP path, SEXP shape_columns)
{
if (!Rf_isFrame(dtaframe))
return showError<false>(L"argument 0 is not a data.frame"), R_NilValue;
//same as narray_tools.cpp
std::wstring dataset_name;
tools::copy_to(path, dataset_name);
struct _cleanup
{
typedef std::vector<cols_base*> c_type;
std::vector<std::string> name;
c_type c;
//std::vector<c_type::const_iterator> shape;
c_type shape;
~_cleanup()
{
for (size_t i = 0; i < c.size(); i++)
delete c[i];
for (size_t i = 0; i < shape.size(); i++)
delete shape[i];
}
}cols;
//cols.name = df.attr("names");
tools::getNames(dtaframe, cols.name);
if (cols.name.empty())
return showError<false>(L"data.frame has 0 column"), R_NilValue;
if (tools::size(dtaframe) != cols.name.size())
return showError<false>(L"unknown"), R_NilValue;
CComPtr<IGPUtilities> ipDEUtil;
if (ipDEUtil.CoCreateInstance(CLSID_GPUtilities) != S_OK)
return showError<true>(L"IDEUtilitiesImpl - CoCreateInstance has failed"), R_NilValue;
HRESULT hr;
//cols.c.resize(cols.name.size(), NULL);
bool isShape = false;
if (shape_columns != R_NilValue)
{
std::vector<std::string> shapes;
tools::copy_to(shape_columns, shapes);
if (shapes.size() < 2 || shapes.size() > 4)
return showError<false>(L"shape expecting 2 strings"), NULL;
isShape = true;
for (size_t i = 0; i < shapes.size(); i++)
{
std::vector<std::string>::iterator it = std::find(cols.name.begin(), cols.name.end(), shapes[i]);
if (it == cols.name.end())
return showError<false>(L"cannot find shape in data.frame"), NULL;
size_t pos = std::distance(cols.name.begin(), it);
cols.shape.push_back(new cols_wrap<double>(VECTOR_ELT(dtaframe, pos)));
//cols.shape.[i] = cols.c.begin() + pos;
it->clear();
}
}
CComPtr<IName> ipName;
if (isShape)
hr = ipDEUtil->CreateFeatureClassName(CComBSTR(dataset_name.c_str()), &ipName);
else
hr = ipDEUtil->CreateTableName(CComBSTR(dataset_name.c_str()), &ipName);
CComQIPtr<IDatasetName> ipDatasetName(ipName);
CComPtr<IWorkspaceName> ipWksName;
CComQIPtr<IWorkspace> ipWks;
if (hr == S_OK)
hr = ipDatasetName->get_WorkspaceName(&ipWksName);
if (hr == S_OK)
{
CComPtr<IUnknown> ipUnk;
hr = CComQIPtr<IName>(ipWksName)->Open(&ipUnk);
ipWks = ipUnk;
}
if (hr != S_OK)
return showError<true>(L"invalid table name"), R_NilValue;
CComQIPtr<IFeatureWorkspace> ipFWKS(ipWks);
ATLASSERT(ipFWKS);
if (!ipFWKS)
return showError<true>(L"not a FeatureWorkspace"), R_NilValue;
CComBSTR bstrTableName;
ipDatasetName->get_Name(&bstrTableName);
/*
CComQIPtr<IWorkspaceSchemaImpl> ipWSchema(ipWks);
if (ipWSchema)
{
VARIANT_BOOL b = VARIANT_FALSE;
ipWSchema->TableExists(bstrTableName, &b);
if (b != VARIANT_FALSE)
return ::Rf_error("table Exists"), NULL;
}*/
CComPtr<IFieldsEdit> ipFields;
//.........这里部分代码省略.........