BOOL IMsoComponentManager.FRegisterComponent( IMsoComponent component, MSOCRINFO *pcrinfo, UIntPtr *pdwComponentID) { if (pcrinfo == null || pdwComponentID == null || pcrinfo->cbSize < sizeof(MSOCRINFO)) { return(BOOL.FALSE); } // Construct Hashtable entry for this component ComponentHashtableEntry entry = new ComponentHashtableEntry { component = component, componentInfo = *pcrinfo }; _cookieCounter += 1; OleComponents.Add(_cookieCounter, entry); // Return the cookie *pdwComponentID = _cookieCounter; Debug.WriteLineIf(CompModSwitches.MSOComponentManager.TraceInfo, $"ComponentManager: Component registered. ID: {_cookieCounter}"); return(BOOL.TRUE); }
BOOL IMsoComponentManager.FUpdateComponentRegistration( UIntPtr dwComponentID, MSOCRINFO *pcrinfo) { // Update the registration info if (pcrinfo == null || !OleComponents.TryGetValue(dwComponentID, out ComponentHashtableEntry entry)) { return(BOOL.FALSE); } entry.componentInfo = *pcrinfo; OleComponents[dwComponentID] = entry; return(BOOL.TRUE); }
BOOL IMsoComponentManager.FGetActiveComponent( msogac dwgac, void **ppic, MSOCRINFO *pcrinfo, uint dwReserved) { IMsoComponent component = dwgac switch { msogac.Active => _activeComponent, msogac.Tracking => _trackingComponent, msogac.TrackingOrActive => _trackingComponent ?? _activeComponent, _ => null }; if (component == null) { return(BOOL.FALSE); } if (pcrinfo != null) { if (pcrinfo->cbSize < sizeof(MSOCRINFO)) { return(BOOL.FALSE); } foreach (ComponentHashtableEntry entry in OleComponents.Values) { if (entry.component == component) { *pcrinfo = entry.componentInfo; break; } } } if (ppic != null) { // This will addref the interface *ppic = (void *)Marshal.GetComInterfaceForObject <IMsoComponent, IMsoComponent>(component); } return(BOOL.TRUE); } }