// 输出日志2,在m_logExplorer写日志 void CLog::DoLog(const CString* output) { if (m_logDocument.p == NULL) { delete output; return; } WriteDocument(*output); delete output; // 滚动到底端 CComPtr<IHTMLElement> body; m_logDocument->get_body(&body); // 取ID static LPOLESTR scrollHeightName = OLESTR("scrollHeight"), scrollTopName = OLESTR("scrollTop"); static DISPID scrollHeightID = -1, scrollTopID = -1; if (scrollHeightID == -1) body->GetIDsOfNames(IID_NULL, &scrollHeightName, 1, LOCALE_SYSTEM_DEFAULT, &scrollHeightID); if (scrollTopID == -1) body->GetIDsOfNames(IID_NULL, &scrollTopName, 1, LOCALE_SYSTEM_DEFAULT, &scrollTopID); // body.scrollTop = body.scrollHeight DISPPARAMS params = {}; _variant_t scrollHeight; #pragma warning(suppress: 6102) if (scrollHeightID != -1) body->Invoke(scrollHeightID, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, ¶ms, scrollHeight.GetAddress(), NULL, NULL); params.cArgs = 1; params.rgvarg = &scrollHeight; #pragma warning(suppress: 6102) if (scrollTopID != -1) body->Invoke(scrollTopID, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, ¶ms, NULL, NULL, NULL); }
STDMETHODIMP ASDTDModel::saveAsText(BSTR *pVal) { if (pVal == NULL) return E_POINTER; CComBSTR text = OLESTR(""); for (int i = 0; i < m_elementDeclarations->m_items.GetSize(); i++) { CASDTDElement* pElement = (CASDTDElement*)m_elementDeclarations->m_items[i]; text += pElement->GetAsText(); if (pElement->m_attributeDecls->m_items.GetSize() > 0) { text += OLESTR("<!ATTLIST "); text += pElement->m_name; text += OLESTR(" "); for (int j = 0; j < pElement->m_attributeDecls->m_items.GetSize(); j++) { CASDTDAttribute* pAttribute = (CASDTDAttribute*)pElement->m_attributeDecls->m_items[j]; text += pAttribute->m_name; text += OLESTR("\n"); } text += OLESTR(">\n"); } } *pVal = text.Detach(); return S_OK; }
da_server * local_host::connect_to( const CLSID clsid ) { ATL::CComPtr<IClassFactory> class_factory_ptr; HRESULT result = ::CoGetClassObject(clsid, CLSCTX_LOCAL_SERVER, NULL, IID_IClassFactory, (void**)&class_factory_ptr); if (FAILED(result)) { throw opc_exception( result, OLESTR("Failed get Class factory") ); } ATL::CComPtr<IUnknown> unknown_ptr; result = class_factory_ptr->CreateInstance(NULL, IID_IUnknown, (void**)&unknown_ptr); if (FAILED(result)) { throw opc_exception( result, OLESTR("Failed get create OPC server ref") ); } ATL::CComPtr<IOPCServer> server_ptr; result = unknown_ptr->QueryInterface(IID_IOPCServer, (void**)&server_ptr); if (FAILED(result)) { throw opc_exception( result, OLESTR("Failed obtain IID_IOPCServer interface from server") ); } return new opc::da_server( server_ptr ); }
STDMETHODIMP CGPAXPlugin::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) { u16 wurl[MAXLEN_URL]; const char *sptr; u16 len; VARIANT value; if( pPropBag == NULL) return E_INVALIDARG; VariantInit(&value); V_VT(&value) = VT_BOOL; V_BOOL(&value) = m_bAutoStart ? VARIANT_TRUE : VARIANT_FALSE; pPropBag->Write(OLESTR("AutoStart"), &value); VariantClear(&value); V_VT(&value) = VT_BSTR; sptr = (const char *)m_url; len = gf_utf8_mbstowcs(wurl, MAXLEN_URL, &sptr); V_BSTR(&value) = SysAllocStringLen(NULL, len+1); memcpy(V_BSTR(&value) , wurl, len*sizeof(u16)); V_BSTR(&value) [len] = 0; pPropBag->Write(OLESTR("src"), &value); VariantClear(&value); return S_OK; }
void initialize() { //HRESULT result = ::CoInitialize(NULL); HRESULT result = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); if (FAILED(result)) { throw opc_exception( result, OLESTR("CoInitialize failed") ); } result = ::CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL); if (FAILED(result)) { throw opc_exception( result, OLESTR("CoInitializeSecurity failed") ); } /* if ( memManager ) { result = ::CoGetMalloc(MEMCTX_TASK, memManager); if (FAILED(result)) { throw opc_exception( result, OLESTR("CoGetMalloc failed") ); } } //*/ }
/** * @param strReportName - report file name. */ void CExpressModeDlg::GetReportFileName(CString& strReportName) { strReportName.Empty(); if (! m_pXMLElementDocument) return; CString strTimeStamp; GetXMLNodeText(m_pXMLElementDocument, OLESTR("./timestamp"), strTimeStamp); if (! strTimeStamp.IsEmpty()) { ULONGLONG uiTimeStamp = _tcstoui64(strTimeStamp, NULL, 0); if (uiTimeStamp != 0) { CString strApplication; GetXMLNodeText(m_pXMLElementDocument, OLESTR("./application"), strApplication); if (! strApplication.IsEmpty()) { int nLength = strApplication.GetLength(); for (int i = 0; i < nLength; ++i) { TCHAR chValue = strApplication.GetAt(i); if (_istalnum(chValue)) strReportName += chValue; } strReportName += _T('_'); } SYSTEMTIME DateTime; GetDateTime(uiTimeStamp, DateTime); CString strTimeStamp; strTimeStamp.Format(_T("error_report_%02d%02d%02d-%02d%02d%02d.log"), DateTime.wYear % 100, DateTime.wMonth, DateTime.wDay, DateTime.wHour, DateTime.wMinute, DateTime.wSecond); strReportName += strTimeStamp; } } }
int StartPlugin(){ //Create an instance of our VB COM object, and execute //one of its methods so that it will load up and show a UI //for us, then it uses our other exports to access olly plugin API //methods CLSID clsid; HRESULT hr; LPOLESTR p = OLESTR("IDACompare.CPlugin"); hr = CoInitialize(NULL); hr = CLSIDFromProgID( p , &clsid); if( hr != S_OK ){ MessageBox(0,"Failed to get Clsid from string\n","",0); return 0; } // create an instance and get IDispatch pointer hr = CoCreateInstance( clsid, NULL, CLSCTX_INPROC_SERVER, IID_IDispatch , (void**) &IDisp ); if ( hr != S_OK ) { MessageBox(0,"CoCreate failed","",0); return 0; } OLECHAR *sMethodName = OLESTR("DoPluginAction"); DISPID dispid; // long integer containing the dispatch ID // Get the Dispatch ID for the method name hr=IDisp->GetIDsOfNames(IID_NULL,&sMethodName,1,LOCALE_USER_DEFAULT,&dispid); if( FAILED(hr) ){ MessageBox(0,"GetIDS failed","",0); return 0; } DISPPARAMS dispparams; VARIANTARG vararg[1]; //function takes one argument VARIANT retVal; VariantInit(&vararg[0]); dispparams.rgvarg = &vararg[0]; dispparams.cArgs = 0; // num of args function takes dispparams.cNamedArgs = 0; // and invoke the method hr=IDisp->Invoke( dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, &retVal, NULL, NULL); return 0; }
STDMETHODIMP CLiveColors::GetInfo(BSTR* psDescription, BSTR* psAuthor, BSTR* psEmail, BSTR* psHomepage) { if (psDescription) *psDescription = OLE2BSTR(OLESTR("Show color values for HEX or RGB defined colors inline in source code")); if (psAuthor) *psAuthor = OLE2BSTR(OLESTR("HippoEDIT")); if (psEmail) *psEmail = OLE2BSTR(OLESTR("*****@*****.**")); if (psHomepage) *psHomepage = OLE2BSTR(OLESTR("http://wiki.hippoedit.com/plugins/live-colors")); return S_OK; }
void P2PFrame::handleEvent(Event* evt) { sysstring type = evt->get_type(); EventPhaseType phase = evt->get_eventPhase(); if (phase != CAPTURING_PHASE) { if (type == OLESTR("click")) { evt->stopPropagation(); Results* pResults = new Results; sysstring searchString = m_searchEdit->GetText(); // TODO, search on all networks for (int i = 0; i < m_Networks->m_itemContainer->GetCount(); i++) { Network* pNetwork = dynamic_cast<Network*>(m_Networks->m_itemContainer->GetItem(i)); pResults->m_query = pNetwork->pP2P->Search(searchString, static_cast<ISearchHitHandler*>(pResults)); // m_GnutellaNetwork->pP2P->Search(searchString, static_cast<ISearchHitHandler*>(pResults)); } // TreeControlContainer* container = new TreeControlContainer; // pResults->m_itemContainer = container; ChildWindow* pWindow = new ChildWindow; pWindow->put_Width(new Length(300, Length::UnitAbsolute)); pWindow->put_Height(new Length(300, Length::UnitAbsolute)); pWindow->put_Content(pResults); pWindow->put_TitleText(searchString); pCanvas->AddChild(pWindow); } else if (type == OLESTR("keydown")) { #if 0 printf("Step Into\n"); OnDebugStepInto(); return; #endif } else if (type == OLESTR("mousedown")) { // OnDebugStepInto(); } } CLXUIWindow::handleEvent(evt); }
BOOL CALLBACK DlgProc(HWND hwnd,UINT Msg,WPARAM wParam,LPARAM lParam) { IWebBrowser2* iWebBrowser; VARIANT varMyURL; CAxWindow WinContainer; LPOLESTR pszName = OLESTR("shell.Explorer.2"); RECT rc; BOOL result = FALSE; switch(Msg) { case WM_INITDIALOG: browserEventListener.setUnloaded(); GetClientRect(hwnd, &rc); WinContainer.Create(hwnd, rc, 0,WS_CHILD |WS_VISIBLE); WinContainer.CreateControl(pszName); WinContainer.QueryControl(__uuidof(IWebBrowser2),(void**)&iWebBrowser); VariantInit(&varMyURL); varMyURL.vt = VT_BSTR; varMyURL.bstrVal = SysAllocString(OLESTR("about:blank")); browserEventListener.Advise(hwnd, iWebBrowser); iWebBrowser-> Navigate2(&varMyURL,0,0,0,0); VariantClear(&varMyURL); iWebBrowser-> Release(); result = TRUE; break; case WM_HTML_ACTION: switch (wParam) { case ACTION_COMMIT: EndDialog(hwnd, ACTION_COMMIT); result = TRUE; break; case ACTION_RETURN: EndDialog(hwnd, ACTION_RETURN); result = TRUE; break; } break; case WM_COMMAND: switch(wParam) { case IDCANCEL: EndDialog(hwnd, ACTION_RETURN); result = TRUE; } break; } return result; }
/** * @param strErrorReason - buffer for error reason. */ void CExpressModeDlg::GetErrorReason(CString& strErrorReason) { strErrorReason.Empty(); if (! m_pXMLNodeError) return; CString strProcessName; GetXMLNodeText(m_pXMLNodeError, OLESTR("./process/name"), strProcessName, _T("UNKNOWN PROCESS")); CString strWhat; GetXMLNodeText(m_pXMLNodeError, OLESTR("./what"), strWhat, _T("UNKNOWN ERROR")); CStackEntry StackEntry; GetStackEntry(m_pXMLNodeError, StackEntry); strErrorReason = strProcessName; strErrorReason += _T(" caused "); strErrorReason += strWhat; if (! StackEntry.m_strModule.IsEmpty()) { strErrorReason += _T(" in module \""); strErrorReason += StackEntry.m_strModule; strErrorReason += _T('\"'); } if (! StackEntry.m_strAddress.IsEmpty()) { strErrorReason += _T(" at "); strErrorReason += StackEntry.m_strAddress; } if (! StackEntry.m_strFunctionInfo.IsEmpty()) { strErrorReason += _T(", "); strErrorReason += StackEntry.m_strFunctionInfo; } if (! StackEntry.m_strSourceFile.IsEmpty()) { strErrorReason += _T(" in \""); strErrorReason += StackEntry.m_strSourceFile; strErrorReason += _T('\"'); } if (! StackEntry.m_strLineInfo.IsEmpty()) { strErrorReason += _T(", "); strErrorReason += StackEntry.m_strLineInfo; } }
// CMSOmniProvRowset :: CreateColInfo // This function creates all of the column information and stores it in the rowset. // It currently uses all of the columns of the table void CMSOmniProvRowset::CreateColInfo() { // check if bookmarks are set bool bUseBookmarks = false; CComVariant varBookmarks; HRESULT hrLocal = GetPropValue(&DBPROPSET_ROWSET, DBPROP_BOOKMARKS, &varBookmarks); bUseBookmarks = (hrLocal == S_OK && varBookmarks.boolVal == VARIANT_TRUE); // get column info from the .INI file DBORDINAL ulNumCols; ATLCOLUMNINFO * prgColInfo = m_DBFile.GetSchemaInfo(&ulNumCols); // Need to add bookmark column info? if (bUseBookmarks) { // create new set of column information which includes bookmarks ATLCOLUMNINFO * prgColInfoNew; prgColInfoNew = new ATLCOLUMNINFO[ulNumCols+1]; // set bindings for the bookmark memset(&prgColInfoNew[0], 0, sizeof(ATLCOLUMNINFO)); prgColInfoNew[0].cbOffset = 0; prgColInfoNew[0].iOrdinal = 0; prgColInfoNew[0].columnid.eKind = DBKIND_NAME; prgColInfoNew[0].columnid.uGuid.guid = GUID_NULL; prgColInfoNew[0].columnid.uName.pwszName = OLESTR("Bookmark"); prgColInfoNew[0].pwszName = OLESTR("Bookmark"); prgColInfoNew[0].wType = DBTYPE_I4; prgColInfoNew[0].ulColumnSize = 4; prgColInfoNew[0].dwFlags = DBCOLUMNFLAGS_ISBOOKMARK; // copy the old information into the new for (DBORDINAL i = 1; i <= ulNumCols; i++) { prgColInfoNew[i] = prgColInfo[i-1]; prgColInfoNew[i].cbOffset +=4; //adjust space for bookmark } ulNumCols++; prgColInfo = prgColInfoNew; } // store column info in the rowset object SetSchemaInfo(prgColInfo, ulNumCols); // 2.0 // Release the temporary prgColInfo delete [] prgColInfo; }
void main(void) { HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED); if (SUCCEEDED(hr)) { { SI(IUnknown) siUnk; hr = siUnk.Instantiate(CLSID_Goodbye); if (SUCCEEDED(hr)) { SI(IHello) siHello = siUnk; siHello->HelloWorld(); } SI(IPersistStorage) sips; hr = sips.BindToObject(_U("D:\\dbox\\courseware\\ecom\\02_cxx.ppt")); SI(IClassFactory) sicf; hr = sicf.GetClassObject(OLESTR("Excel.Sheet")); SI(IUnknown) p1; hr = sicf->CreateInstance(0, IID_PPV(p1)); hr = OleRun(p1.GetNonAddRefedInterface()); } CoUninitialize(); } }
HRESULT CPigEngine::get_AccountDispenser(IPigAccountDispenser** ppDispenser) { // Get the computer name of the account server CComBSTR bstrServer; RETURN_FAILED(get_AccountServer(&bstrServer)); if (!bstrServer.Length()) { // Get the computer name of the mission server RETURN_FAILED(get_MissionServer(&bstrServer)); } // Check for '.' to indicate this computer if (1 == bstrServer.Length() && OLESTR('.') == bstrServer[0]) bstrServer.Empty(); // Create the Pig Account Dispenser on the mission server COSERVERINFO si = {0, bstrServer, NULL, 0}; MULTI_QI mqi = {&IID_IPigAccountDispenser, NULL, S_OK}; RETURN_FAILED(CoCreateInstanceEx(CLSID_PigAccountDispenser, NULL, CLSCTX_SERVER, &si, 1, &mqi)); // Copy the interface pointer to the [out] parameter ZSucceeded(mqi.hr); *ppDispenser = (IPigAccountDispenser*)mqi.pItf; // Indicate success return S_OK; }
//============================================== int g_InitActX_Control( HWND hWnd) { IUnknown * pUnk; IUnknown * pUnkCont; HRESULT hRet; x_pIFactory = new CFactory(); if( x_pIFactory == NULL) return 2; hRet = CoRegisterClassObject( CLSID_CP_TimeSyncClass, //Class identifier (CLSID) to be registered x_pIFactory, //Pointer to the class object CLSCTX_LOCAL_SERVER, //Context for running executable code REGCLS_MULTIPLEUSE, // multiple clients for the same server, we do not start a new server for each client &x_dwRegister ); //Save registered object info, for future release by CoRevokeClassObject() if( hRet != S_OK) return 3; // Initialize ATL control containment code. AtlAxWinInit(); // Create ActiveX control using the window handle // and get the IUnknown interface of this control hRet = AtlAxCreateControlEx( OLESTR("RPco.X"), hWnd, NULL, &pUnkCont, &pUnk, IID_NULL, NULL ); // Obtain smart pointer to TDevAccX using IUnknown of the control g_pRPcoX = pUnk; pUnk->Release(); return 0; }
// I need to make sure the file is registered with long filenames HRESULT WINAPI CXMLDOMDocument::UpdateRegistry(BOOL bRegister) { USES_CONVERSION; TCHAR file[MAX_PATH]; if (::GetModuleFileName(_Module.m_hInst, file, MAX_PATH)) { WIN32_FIND_DATA d; memset(&d,0,sizeof(WIN32_FIND_DATA)); HANDLE h = FindFirstFile(file,&d); if (h != INVALID_HANDLE_VALUE) { TCHAR *name = _tcsrchr(file,_T('\\')); TCHAR newFile[MAX_PATH] = _T(""); _tcsncpy(newFile,file,name-file); _tcscat(newFile,_T("\\")); _tcscat(newFile,d.cFileName); FindClose(h); _ATL_REGMAP_ENTRY regmap[2] = {{NULL,NULL},{NULL,NULL}}; regmap[0].szKey = OLESTR("XMLMODULE"); regmap[0].szData = T2OLE(newFile); return _Module.UpdateRegistryFromResource((UINT) IDR_XMLDOCUMENT, bRegister,regmap); } } return E_FAIL; }
STDMETHODIMP CPluginImpl::raw_Terminate() { try { if ( NULL != customDirController_ ) { GrymCore::IStdDirectoryCustomControllerContainerPtr controllerContainer = g_pi.baseView->Frame->DirectoryCollection->GetDirectory(OLESTR("Grym.DirPage.Org")); controllerContainer->UnregisterController(customDirController_); } if ( NULL != searchGroup_ && NULL != ctrlSearch_ ) GrymCore::IControlSetPtr(searchGroup_)->RemoveControl(ctrlSearch_); if ( NULL != toolsGroup_ && NULL != cmdExport_ ) GrymCore::IControlSetPtr(searchGroup_)->RemoveControl(cmdExport_); ctrlSearch_ = NULL; cmdExport_ = NULL; searchGroup_ = NULL; toolsGroup_ = NULL; customDirController_ = NULL; g_pi.baseView = NULL; g_pi.grymApp = NULL; } catch(...) { } return S_OK; }
void ResultItem::handleEvent(Event* evt) { sysstring type = evt->get_type(); EventPhaseType phase = evt->get_eventPhase(); if (phase != CAPTURING_PHASE) { #if 0 if (type == OLESTR("Activate")) { evt->stopPropagation(); IItemSite* itemsite = dynamic_cast<IItemSite*>(evt->get_target()); SHA1DigestField* sha1 = dynamic_cast<SHA1DigestField*>(itemsite->GetFieldData(4)); ByteStreamWriter* file = new ByteStreamWriter(ConvertS2A(dynamic_cast<TextString*>(itemsite->GetFieldUI(0))->get_textContent()).c_str()); pP2P->Download(m_size->m_value, m_sha1->m_buffer, m_Downloads, file); /* DownloadItem* item = new DownloadItem; item->m_uiFilename = new TextString(L"Test");//new TextString(m_uiFilename->get_textContent()); item->m_site = m_Downloads->m_itemContainer->AddItem(item); item->m_uiSize = dynamic_cast<LongLongField*>(itemsite->GetFieldData(1))->m_value; memcpy(item->m_digest, sha1->m_buffer, 20); */ // item->m_QueryHitData = m_QueryHitData; //item->Download(); } #endif } }
HRESULT RegisterCategory() { HRESULT hresult; ICatRegister *pCatRegister; CATID usedCategoryIds[1]; CATEGORYINFO categoryInfo[1]; hresult = CoCreateInstance(CLSID_StdComponentCategoriesMgr,0,CLSCTX_ALL, IID_ICatRegister,(void**) &pCatRegister); if (SUCCEEDED(hresult)) { categoryInfo[0].catid = CATID_4ControlProjectWizard; categoryInfo[0].lcid = MAKELCID( MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT),SORT_DEFAULT); wcscpy(categoryInfo[0].szDescription,OLESTR("4ControlProjectWizardCategory")); hresult = pCatRegister->RegisterCategories( sizeof(categoryInfo)/sizeof(*categoryInfo),categoryInfo); if (SUCCEEDED(hresult)) { usedCategoryIds[0] = CATID_4ControlProjectWizard; hresult = pCatRegister->RegisterClassImplCategories( CLSID_WizardComObj, sizeof(usedCategoryIds)/sizeof(*usedCategoryIds), usedCategoryIds); } pCatRegister->Release(); } return hresult; }
local_host::local_host() { HRESULT result = ::CoCreateInstance (CLSID_StdComponentCategoriesMgr, NULL,CLSCTX_INPROC_SERVER, IID_ICatInformation,(void **)&root_); if (FAILED(result)) { throw opc_exception( result, OLESTR("Failed to get IID_ICatInformation") ); } }
static inline UINT WINAPI GetDirLen(LPCOLESTR lpszPathName) throw() { ATLASSERT(lpszPathName != NULL); // always capture the complete file name including extension (if present) LPCOLESTR lpszTemp = lpszPathName; for (LPCOLESTR lpsz = lpszPathName; *lpsz != NULL; ) { LPCOLESTR lp = CharNextW(lpsz); // remember last directory/drive separator if (*lpsz == OLESTR('\\') || *lpsz == OLESTR('/') || *lpsz == OLESTR(':')) lpszTemp = lp; lpsz = lp; } return UINT( lpszTemp-lpszPathName ); }
GrymCore::ISearchGroupControlPtr COrgSearchControl::CreateInstance() { ATL::CComObject<COrgSearchControl> *obj; ATLVERIFY(S_OK == ATL::CComObject<COrgSearchControl>::CreateInstance(&obj)); GrymCore::ISearchGroupControlPtr rv = obj; ATLASSERT(NULL != rv); obj->tag_ = OLESTR("FirstAidKit.MainTab.SearchControl"); obj->placement_code_ = OLESTR("<control_pos>") OLESTR("<size min_width=\"150\" max_width=\"300\" height_in_rows=\"1\" />") OLESTR("<position column_id=\"100SearchGroup\" row_id=\"500MyRowByID\" order_in_row=\"1\" />") OLESTR("</control_pos>"); obj->AdjustEditControl(g_pi.baseView->Factory); return rv; }
DmSoft::DmSoft(){ WinExec("regsvr32 /s dm.dll", SW_HIDE); //?注册 CoInitialize(NULL); CLSID clsid; //?利用“根名称.类名”获取CLSID,&就是把指针给函数,也就是传址 HRESULT hr = CLSIDFromProgID(OLESTR("dm.dmsoft"), &clsid); dmSoft.CreateDispatch(clsid); }
HRESULT STDMETHODCALLTYPE CIEHtmlElementCollection::toString(BSTR __RPC_FAR *String) { if (String == NULL) { return E_INVALIDARG; } *String = SysAllocString(OLESTR("ElementCollection")); return S_OK; }
static ULONG GetSpatialParamOrdinal(const OLECHAR *paramName) { static const OLECHAR *paramNames[] = { OLESTR( "FILTER" ), OLESTR( "OPERATOR" ), OLESTR( "COL_NAME" ) }; for (int i = 0; i < sizeof(paramNames)/sizeof(paramNames[0]); i++) { if (_wcsicmp(paramNames[i], paramName) == 0) { return i + 1; } } return 0; }
item::item( LPCWSTR name, bool active, group& g ) : owner_(g) , name_( lstrlenW( name ) + 1 ) { lstrcpynW( &name_[0], name, static_cast<int>( name_.size() ) ); client_ = OPCHANDLE( intptr_t( this ) ); OPCITEMDEF itemDef; itemDef.szItemID = &name_[0]; itemDef.szAccessPath = NULL; itemDef.bActive = active ? TRUE : FALSE; itemDef.hClient = client_; itemDef.dwBlobSize = 0; itemDef.pBlob = NULL; itemDef.vtRequestedDataType = VT_EMPTY; cotask_holder< HRESULT > itemResult; cotask_holder< OPCITEMRESULT > itemDetails; HRESULT result = owner_.item_mgt()->AddItems( 1, &itemDef, itemDetails.addr(), itemResult.addr() ); if (FAILED(result)) { #if defined _DEBUG && defined _CONSOLE wprintf( L"item::item( %s ) failed! HR = 0x%x\n", name, result ); #endif throw opc_exception( result, OLESTR("Failed to add item") ); } #if defined _DEBUG && defined _CONSOLE wprintf( L"item::item( %s ) created! hClient = 0x%X\n", name, itemDef.hClient ); #endif cotask_holder< BYTE > blobHolder( itemDetails[0].pBlob ); if ( FAILED(itemResult[0]) ) { throw opc_exception( result, OLESTR("Failed to add item") ); } handle_ = itemDetails[0].hServer; data_type_ = itemDetails[0].vtCanonicalDataType; access_rights_ = itemDetails[0].dwAccessRights; }
void item::data::set(FILETIME time, WORD qual, VARIANT & val) { HRESULT result = VariantCopy( &vDataValue, &val); if (FAILED(result)) { throw opc_exception( result, OLESTR("VarCopy failed") ); } ftTimeStamp = time; wQuality = qual; }
STDMETHODIMP COrgSearchControl::raw_Clear() { try { grymEditControl_->EditText = OLESTR(""); return S_OK; } catch (...) { } return E_FAIL; }
void item::data::set(OPCITEMSTATE &itemState) { HRESULT result = VariantCopy( &vDataValue, &itemState.vDataValue); if (FAILED(result)) { throw opc_exception( result, OLESTR("VarCopy failed") ); } ftTimeStamp = itemState.ftTimeStamp; wQuality = itemState.wQuality; }
void item::read( data& v, OPCDATASOURCE source ) { cotask_holder<HRESULT> itemResult; cotask_holder<OPCITEMSTATE> itemState; HRESULT result = owner_.sync_io()->Read(source, 1, &handle_, itemState.addr(), itemResult.addr()); if (FAILED(result)) { throw opc_exception( result, OLESTR("Read failed") ); } if (FAILED(itemResult[0])) { throw opc_exception( itemResult[0], OLESTR("Read failed") ); } v.set(itemState[0]); VariantClear(&itemState[0].vDataValue); }