Пример #1
0
HRESULT __stdcall Factory::CreateInstance(IUnknown* pUnknownOuter, const IID& iid, void** ppv) {
    if (pUnknownOuter)
        return CLASS_E_NOAGGREGATION;

    switch (type) {
        case FactoryIconHandler:
            if (iid == IID_IUnknown || iid == IID_IShellIconOverlayIdentifier) {
                BtrfsIconOverlay* bio = new BtrfsIconOverlay;
                if (!bio)
                    return E_OUTOFMEMORY;

                return bio->QueryInterface(iid, ppv);
            }
            break;
            
        case FactoryContextMenu:
            if (iid == IID_IUnknown || iid == IID_IContextMenu || iid == IID_IShellExtInit) {
                BtrfsContextMenu* bcm = new BtrfsContextMenu;
                if (!bcm)
                    return E_OUTOFMEMORY;
                
                return bcm->QueryInterface(iid, ppv);
            }
            break;
            
        case FactoryPropSheet:
            if (iid == IID_IUnknown || iid == IID_IShellPropSheetExt || iid == IID_IShellExtInit) {
                BtrfsPropSheet* bps = new BtrfsPropSheet;
                if (!bps)
                    return E_OUTOFMEMORY;
                
                return bps->QueryInterface(iid, ppv);
            }
            break;
            
        default:
            break;
    }
    
    *ppv = NULL;
    return E_NOINTERFACE;
}
Пример #2
0
HRESULT __stdcall Factory::CreateInstance(IUnknown* pUnknownOuter, const IID& iid, void** ppv) {
    if (pUnknownOuter)
        return CLASS_E_NOAGGREGATION;

    if (iid == IID_IUnknown || iid == IID_IShellIconOverlayIdentifier) {
        BtrfsIconOverlay* bio = new BtrfsIconOverlay;
        if (!bio)
            return E_OUTOFMEMORY;

        return bio->QueryInterface(iid, ppv);
    } else if (iid == IID_IContextMenu || iid == IID_IShellExtInit) {
        BtrfsContextMenu* bcm = new BtrfsContextMenu;
        if (!bcm)
            return E_OUTOFMEMORY;
        
        return bcm->QueryInterface(iid, ppv);
    }
    
    *ppv = NULL;
    return E_NOINTERFACE;
}