kernel: Better support for detached processes.
[wine/gsoc_dplay.git] / dlls / objsel / factory.c
blobdafbfcd1bf18f80dfe3e0de3e89b7008768f89aa
1 /*
2 * ClassFactory implementation for OBJSEL.dll
4 * Copyright (C) 2002 John K. Hohm
5 * Copyright (C) 2002 Robert Shearman
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "objsel_private.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(objsel);
29 /**********************************************************************
30 * OBJSEL_IClassFactory_QueryInterface (also IUnknown)
32 static HRESULT WINAPI OBJSEL_IClassFactory_QueryInterface(
33 LPCLASSFACTORY iface,
34 REFIID riid,
35 LPVOID *ppvObj)
37 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
39 if (ppvObj == NULL) return E_POINTER;
41 if (IsEqualGUID(riid, &IID_IUnknown) ||
42 IsEqualGUID(riid, &IID_IClassFactory))
44 *ppvObj = (LPVOID)iface;
45 IClassFactory_AddRef(iface);
46 return S_OK;
48 else if (IsEqualGUID(riid, &IID_IDsObjectPicker))
50 return IClassFactory_CreateInstance(iface, NULL, riid, ppvObj);
53 FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
54 return E_NOINTERFACE;
58 /**********************************************************************
59 * OBJSEL_IClassFactory_AddRef (also IUnknown)
61 static ULONG WINAPI OBJSEL_IClassFactory_AddRef(LPCLASSFACTORY iface)
63 ClassFactoryImpl *This = (ClassFactoryImpl *)iface;
64 ULONG ref;
66 TRACE("\n");
68 if (This == NULL) return E_POINTER;
70 ref = InterlockedIncrement(&This->ref);
72 if (ref == 1)
74 InterlockedIncrement(&dll_refs);
77 return ref;
81 /**********************************************************************
82 * OBJSEL_IClassFactory_Release (also IUnknown)
84 static ULONG WINAPI OBJSEL_IClassFactory_Release(LPCLASSFACTORY iface)
86 ClassFactoryImpl *This = (ClassFactoryImpl *)iface;
87 ULONG ref;
89 TRACE("\n");
91 if (This == NULL) return E_POINTER;
93 ref = InterlockedDecrement(&This->ref);
95 if (ref == 0)
97 InterlockedDecrement(&dll_refs);
100 return ref;
104 /**********************************************************************
105 * OBJSEL_IClassFactory_CreateInstance
107 static HRESULT WINAPI OBJSEL_IClassFactory_CreateInstance(
108 LPCLASSFACTORY iface,
109 LPUNKNOWN pUnkOuter,
110 REFIID riid,
111 LPVOID *ppvObj)
113 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
115 if (ppvObj == NULL) return E_POINTER;
117 /* Don't support aggregation (Windows doesn't) */
118 if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
120 if (IsEqualGUID(&IID_IDsObjectPicker, riid))
122 return OBJSEL_IDsObjectPicker_Create(ppvObj);
125 return CLASS_E_CLASSNOTAVAILABLE;
129 /**********************************************************************
130 * OBJSEL_IClassFactory_LockServer
132 static HRESULT WINAPI OBJSEL_IClassFactory_LockServer(
133 LPCLASSFACTORY iface,
134 BOOL fLock)
136 TRACE("\n");
138 if (fLock)
139 IClassFactory_AddRef(iface);
140 else
141 IClassFactory_Release(iface);
142 return S_OK;
146 /**********************************************************************
147 * IClassFactory_Vtbl
149 static IClassFactoryVtbl IClassFactory_Vtbl =
151 OBJSEL_IClassFactory_QueryInterface,
152 OBJSEL_IClassFactory_AddRef,
153 OBJSEL_IClassFactory_Release,
154 OBJSEL_IClassFactory_CreateInstance,
155 OBJSEL_IClassFactory_LockServer
159 /**********************************************************************
160 * static ClassFactory instance
163 ClassFactoryImpl OBJSEL_ClassFactory = { &IClassFactory_Vtbl, 0 };