HRESULT CComModule::ProcessError(HRESULT hr, RCString desc) { //!!!#if !UCFG_WCE AFX_MODULE_STATE *pMS = AfxGetModuleState(); CComPtr<ICreateErrorInfo> iCEI; OleCheck(::CreateErrorInfo(&iCEI)); String s = desc; if (s.IsEmpty()) s = AfxProcessError(hr); OleCheck(iCEI->SetDescription(Bstr(s))); CComPtr<IErrorInfo> iEI = iCEI; OleCheck(::SetErrorInfo(0, iEI)); //#endif return hr; }
AnsiString CreateGuid(void) { System::TGUID g; OleCheck (CoCreateGuid (&g)); return (Sysutils::GUIDToString (g)); }
void PrintDoc(seakgOutput *pOutput, UnicodeString filename, UnicodeString name, UnicodeString uuid, UnicodeString code) { filename = filename.SubString(rootPath.Length()+1, filename.Length() - rootPath.Length()); UnicodeString id = ""; // UnicodeString id = ""; code = encoding_html(code); name = encoding_html(name); TGUID g; OleCheck(CoCreateGuid(&g)); //Sysutils::GUIDToString(g); //id = Sysutils::GUIDToString(g); //id = id.SubString(2,37) + "[" + IntToStr(g_nInc++) + "]"; id = IntToStr(g_nInc++); while (id.Length() < 6) id = "0" + id; id = prefixforid + id; pOutput->addline("\t<doc>"); pOutput->addline("\t\t<field name=\"id\">" + id + "</field>"); pOutput->addline("\t\t<field name=\"project\">" + projectName + "</field>"); pOutput->addline("\t\t<field name=\"name\">" + name + "</field>"); pOutput->addline("\t\t<field name=\"uuid\">" + uuid.UpperCase() + "</field>"); pOutput->addline("\t\t<field name=\"source_filepath\">" + filename + "</field>"); pOutput->addline("\t\t<field name=\"full_source_code\">\n" + code + "\n\t\t</field>"); pOutput->addline("\t</doc>"); };
ITypeInfo *CComClass::GetTypeInfo(const IID *piid) { if (m_iid == *piid) return m_iTI; CTypeInfoMap::iterator i = m_mapTI.find(*piid); if (i != m_mapTI.end()) return i->second; CComPtr<ITypeInfo> iTI; OleCheck(AfxGetModuleState()->m_typeLib.m_iTypeLib->GetTypeInfoOfGuid(*piid, &iTI)); m_mapTI[*piid] = iTI; //!!! SetAt m_iid = *piid; m_iTI = iTI; return iTI; }
void CComTypeLibHolder::Load() { OleCheck(m_libid == GUID_NULL ? ::LoadTypeLib(AfxGetModuleState()->FileName, &m_iTypeLib) : ::LoadRegTypeLib(m_libid, m_verMajor, m_verMinor, m_lcid, &m_iTypeLib)); }
//--------------------------------------------------------------------------- IShellLink * __fastcall CreateDesktopShortCut(const UnicodeString & Name, const UnicodeString &File, const UnicodeString & Params, const UnicodeString & Description, int SpecialFolder, int IconIndex, bool Return) { IShellLink* pLink = NULL; if (SpecialFolder < 0) { SpecialFolder = CSIDL_DESKTOPDIRECTORY; } try { if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **) &pLink))) { try { pLink->SetPath(File.c_str()); pLink->SetDescription(Description.c_str()); pLink->SetArguments(Params.c_str()); pLink->SetShowCmd(SW_SHOW); // Explicitly setting icon file, // without this icons are not shown at least in Windows 7 jumplist pLink->SetIconLocation(File.c_str(), IconIndex); IPersistFile* pPersistFile; if (!Return && SUCCEEDED(pLink->QueryInterface(IID_IPersistFile, (void **)&pPersistFile))) { try { LPMALLOC ShellMalloc; LPITEMIDLIST DesktopPidl; wchar_t DesktopDir[MAX_PATH]; OleCheck(SHGetMalloc(&ShellMalloc)); try { OleCheck(SHGetSpecialFolderLocation(NULL, SpecialFolder, &DesktopPidl)); OleCheck(SHGetPathFromIDList(DesktopPidl, DesktopDir)); } __finally { ShellMalloc->Free(DesktopPidl); ShellMalloc->Release(); } WideString strShortCutLocation(DesktopDir); // Name can contain even path (e.g. to create quick launch icon) strShortCutLocation += UnicodeString(L"\\") + Name + L".lnk"; OleCheck(pPersistFile->Save(strShortCutLocation.c_bstr(), TRUE)); } __finally { pPersistFile->Release(); } } // this is necessary for Windows 7 taskbar jump list links IPropertyStore * PropertyStore; if (SUCCEEDED(pLink->QueryInterface(IID_IPropertyStore, (void**)&PropertyStore))) { PROPVARIANT Prop; Prop.vt = VT_LPWSTR; Prop.pwszVal = Name.c_str(); PropertyStore->SetValue(PKEY_Title, Prop); PropertyStore->Commit(); PropertyStore->Release(); } } catch(...) { pLink->Release(); throw; } if (!Return) { pLink->Release(); pLink = NULL; } } } catch(Exception & E) { throw ExtException(&E, LoadStr(CREATE_SHORTCUT_ERROR)); } return pLink; }