static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType, LPOLESTR* pszUserType) { WebBrowser *This = impl_from_IOleObject(iface); TRACE("(%p, %d, %p)\n", This, dwFormOfType, pszUserType); return OleRegGetUserType(&CLSID_WebBrowser, dwFormOfType, pszUserType); }
static void get_descriptors(HWND hdlg, ps_struct_t *ps_struct) { FORMATETC fmtetc; STGMEDIUM stg; fmtetc.tymed = TYMED_HGLOBAL; fmtetc.dwAspect = DVASPECT_CONTENT; fmtetc.ptd = NULL; fmtetc.lindex = -1; fmtetc.cfFormat = cf_object_descriptor; if(IDataObject_GetData(ps_struct->ps->lpSrcDataObj, &fmtetc, &stg) == S_OK) { OBJECTDESCRIPTOR *obj_desc = GlobalLock(stg.u.hGlobal); if(obj_desc->dwSrcOfCopy) ps_struct->source_name = strdupW((WCHAR*)((char*)obj_desc + obj_desc->dwSrcOfCopy)); if(obj_desc->dwFullUserTypeName) ps_struct->type_name = strdupW((WCHAR*)((char*)obj_desc + obj_desc->dwFullUserTypeName)); OleRegGetUserType(&obj_desc->clsid, USERCLASSTYPE_APPNAME, &ps_struct->app_name); /* Get the icon here. If dwDrawAspect & DVASCPECT_ICON call GetData(CF_METAFILEPICT), otherwise native calls OleGetIconFromClass(obj_desc->clsid) */ GlobalUnlock(stg.u.hGlobal); GlobalFree(stg.u.hGlobal); } else { /* Try to get some data using some of the other clipboard formats */ } fmtetc.cfFormat = cf_link_src_descriptor; if(IDataObject_GetData(ps_struct->ps->lpSrcDataObj, &fmtetc, &stg) == S_OK) { OBJECTDESCRIPTOR *obj_desc = GlobalLock(stg.u.hGlobal); if(obj_desc->dwSrcOfCopy) ps_struct->link_source_name = strdupW((WCHAR*)((char*)obj_desc + obj_desc->dwSrcOfCopy)); if(obj_desc->dwFullUserTypeName) ps_struct->link_type_name = strdupW((WCHAR*)((char*)obj_desc + obj_desc->dwFullUserTypeName)); GlobalUnlock(stg.u.hGlobal); GlobalFree(stg.u.hGlobal); } if(ps_struct->source_name == NULL && ps_struct->link_source_name == NULL) { WCHAR buf[200]; LoadStringW(OLEDLG_hInstance, IDS_PS_UNKNOWN_SRC, buf, sizeof(buf)/sizeof(WCHAR)); ps_struct->source_name = strdupW(buf); } if(ps_struct->type_name == NULL && ps_struct->link_type_name == NULL) { WCHAR buf[200]; LoadStringW(OLEDLG_hInstance, IDS_PS_UNKNOWN_TYPE, buf, sizeof(buf)/sizeof(WCHAR)); ps_struct->type_name = strdupW(buf); } }
SCODE AFXAPI _AfxOleDoConvert(LPSTORAGE lpStg, REFCLSID rClsidNew) { SCODE sc; CLSID clsidOld; if ((sc = ReadClassStg(lpStg, &clsidOld)) != S_OK) { clsidOld = CLSID_NULL; return sc; } // read old fmt/old user type; sets out params to NULL on error CLIPFORMAT cfOld; LPOLESTR lpszOld = NULL; sc = ReadFmtUserTypeStg(lpStg, &cfOld, &lpszOld); ASSERT(sc == S_OK || (cfOld == 0 && lpszOld == NULL)); // get new user type name; if error, set to NULL string OLECHAR chZero = 0; LPOLESTR lpszNew = NULL; if (OleRegGetUserType(rClsidNew, USERCLASSTYPE_FULL, &lpszNew) != S_OK) lpszNew = &chZero; // write class stg if ((sc = WriteClassStg(lpStg, rClsidNew)) != S_OK) goto ErrorReturn; // write old fmt/new user type; if ((sc = WriteFmtUserTypeStg(lpStg, cfOld, lpszNew)) != S_OK) goto RewriteInfo; // set convert bit if ((sc = SetConvertStg(lpStg, TRUE)) != S_OK) goto RewriteInfo; goto ErrorReturn; RewriteInfo: WriteClassStg(lpStg, clsidOld); WriteFmtUserTypeStg(lpStg, cfOld, lpszOld); ErrorReturn: if (lpszNew != &chZero) CoTaskMemFree(lpszNew); CoTaskMemFree(lpszOld); return sc; }
///////////////////////////////////////////////////////////////////////////// // Default constructor // // The default constructor extracts the adaptor "friendly name" from the // program name in the registry (where it is put by the DECLARE_REGISTRY // macro. // Function is NOT MODIFIED for the simple adaptor. ///////////////////////////////////////////////////////////////////////////// Cadvantechadapt::Cadvantechadapt() { if (ConstructorName[0]=='\0') { LPOLESTR str=NULL; HRESULT res = OleRegGetUserType( CLSID_advantechadapt, USERCLASSTYPE_SHORT, &str ); if (SUCCEEDED(res)) // if this fails the else probaby will to.. { StringToLower(str,ConstructorName); } else { wcscpy(ConstructorName,L"Constructor Name not found!!!"); } CoTaskMemFree(str); } } // end of default constructor
COleConvertDialog::COleConvertDialog(COleClientItem* pItem, DWORD dwFlags, CLSID* pClassID, CWnd* pParentWnd) : COleDialog(pParentWnd) { if (pItem != NULL) ASSERT_VALID(pItem); ASSERT(pClassID == NULL || AfxIsValidAddress(pClassID, sizeof(CLSID), FALSE)); memset(&m_cv, 0, sizeof(m_cv)); // initialize structure to 0/NULL if (pClassID != NULL) m_cv.clsid = *pClassID; // fill in common part m_cv.cbStruct = sizeof(m_cv); m_cv.dwFlags = dwFlags; if (!afxData.bWin4 && AfxHelpEnabled()) m_cv.dwFlags |= CF_SHOWHELPBUTTON; m_cv.lpfnHook = AfxOleHookProc; m_nIDHelp = AFX_IDD_CONVERT; // specific to this dialog m_cv.fIsLinkedObject = pItem->GetType() == OT_LINK; m_cv.dvAspect = pItem->GetDrawAspect(); if (pClassID == NULL && !m_cv.fIsLinkedObject) { // for embeddings, attempt to get class ID from the storage if (ReadClassStg(pItem->m_lpStorage, &m_cv.clsid) == S_OK) pClassID = &m_cv.clsid; // attempt to get user type from storage CLIPFORMAT cf = 0; LPOLESTR lpOleStr = NULL; ReadFmtUserTypeStg(pItem->m_lpStorage, &cf, &lpOleStr); m_cv.lpszUserType = TASKSTRINGOLE2T(lpOleStr); m_cv.wFormat = (WORD)cf; } // get class id if neded if (pClassID == NULL) { // no class ID in the storage, use class ID of the object pItem->GetClassID(&m_cv.clsid); } // get user type if needed if (m_cv.lpszUserType == NULL) { // no user type in storge, get user type from class ID LPTSTR lpszUserType = NULL; LPOLESTR lpOleStr = NULL; if (OleRegGetUserType(m_cv.clsid, USERCLASSTYPE_FULL, &lpOleStr) == S_OK) { lpszUserType = TASKSTRINGOLE2T(lpOleStr); } else { lpszUserType = (LPTSTR)CoTaskMemAlloc(256 * sizeof(TCHAR)); if (lpszUserType != NULL) { lpszUserType[0] = '?'; lpszUserType[1] = 0; VERIFY(AfxLoadString(AFX_IDS_UNKNOWNTYPE, lpszUserType) != 0); } } m_cv.lpszUserType = lpszUserType; } m_cv.hMetaPict = pItem->GetIconicMetafile(); }
void CInsertControlDlg::RefreshControlList() { BOOL tDone; HRESULT hResult; IEnumGUIDPtr pEnum; ULONG nImplementedCategories; CATID* pcatidImpl; ULONG nRequiredCategories; CATID* pcatidReq; CLSID clsid; LPOLESTR pszName; CString strName; ULONG iCategory; int iItem; POSITION posControl; CString strServerPath; CString strString; m_lbControls.ResetContent(); m_lControls.RemoveAll(); nImplementedCategories = (ULONG)m_aImplementedCategories.GetSize(); if( nImplementedCategories == 0 ) { nImplementedCategories = ULONG( -1 ); pcatidImpl = NULL; } else { pcatidImpl = (CATID*)_malloca( nImplementedCategories*sizeof( CATID ) ); for( iCategory = 0; iCategory < nImplementedCategories; iCategory++ ) { pcatidImpl[iCategory] = m_aImplementedCategories[iCategory]; } } if( m_butIgnoreRequiredCategories.GetCheck() ) { nRequiredCategories = ULONG( -1 ); pcatidReq = NULL; } else { nRequiredCategories = (ULONG)m_aRequiredCategories.GetSize(); if( nRequiredCategories == 0 ) { pcatidReq = NULL; } else { pcatidReq = (CATID*)_malloca( nRequiredCategories*sizeof( CATID ) ); for( iCategory = 0; iCategory < nRequiredCategories; iCategory++ ) { pcatidReq[iCategory] = m_aRequiredCategories[iCategory]; } } } hResult = m_pCatInfo->EnumClassesOfCategories( nImplementedCategories, pcatidImpl, nRequiredCategories, pcatidReq, &pEnum ); _freea(pcatidImpl); _freea(pcatidReq); if( FAILED( hResult ) ) { return; } tDone = FALSE; int nExtent = 0; TEXTMETRIC tm; ::ZeroMemory(&tm, sizeof(TEXTMETRIC)); CFont *pFont = NULL; CFont *pOldFont = NULL; CDC *pDC = m_lbControls.GetDC(); ASSERT(pDC); if (pDC) { pFont = m_lbControls.GetFont(); ASSERT(pFont); if (pFont) { pOldFont = pDC->SelectObject(pFont); VERIFY(pDC->GetTextMetrics(&tm)); } } while( !tDone ) { hResult = pEnum->Next( 1, &clsid, NULL ); if( hResult == S_OK ) { pszName = NULL; hResult = OleRegGetUserType( clsid, USERCLASSTYPE_FULL, &pszName ); if( SUCCEEDED( hResult ) ) { strName = pszName; CoTaskMemFree( pszName ); pszName = NULL; if (pDC && pFont) { CSize sz = pDC->GetTextExtent(strName); if (sz.cx > nExtent) nExtent = sz.cx; } iItem = m_lbControls.AddString( strName ); posControl = m_lControls.AddTail( clsid ); m_lbControls.SetItemDataPtr( iItem, posControl ); } } else { tDone = TRUE; } } if (pDC && pFont) { pDC->SelectObject(pOldFont); m_lbControls.SetHorizontalExtent(nExtent + tm.tmAveCharWidth); } OnControlsSelChange(); }