2 * Copyright (C) 2002 Aric Stewart for CodeWeavers
3 * Copyright (C) 2009 Damjan Jovanovic
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(sti
);
37 extern HRESULT WINAPI
STI_DllGetClassObject(REFCLSID
, REFIID
, LPVOID
*);
38 extern BOOL WINAPI
STI_DllMain(HINSTANCE
, DWORD
, LPVOID
);
39 extern HRESULT WINAPI
STI_DllRegisterServer(void);
40 extern HRESULT WINAPI
STI_DllUnregisterServer(void);
42 typedef HRESULT (*fnCreateInstance
)(REFIID riid
, IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
46 IClassFactory IClassFactory_iface
;
47 fnCreateInstance pfnCreateInstance
;
50 static inline sti_cf
*impl_from_IClassFactory( IClassFactory
*iface
)
52 return CONTAINING_RECORD(iface
, sti_cf
, IClassFactory_iface
);
55 static HRESULT
sti_create( REFIID riid
, IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
57 if (pUnkOuter
!= NULL
&& !IsEqualIID(riid
, &IID_IUnknown
))
58 return CLASS_E_NOAGGREGATION
;
60 if (IsEqualGUID(riid
, &IID_IUnknown
))
61 return StiCreateInstanceW(GetCurrentProcess(), STI_VERSION_REAL
| STI_VERSION_FLAG_UNICODE
, (PSTIW
*) ppObj
, pUnkOuter
);
62 else if (IsEqualGUID(riid
, &IID_IStillImageW
))
63 return StiCreateInstanceW(GetCurrentProcess(), STI_VERSION_REAL
| STI_VERSION_FLAG_UNICODE
, (PSTIW
*) ppObj
, NULL
);
64 else if (IsEqualGUID(riid
, &IID_IStillImageA
))
65 return StiCreateInstanceA(GetCurrentProcess(), STI_VERSION_REAL
, (PSTIA
*) ppObj
, NULL
);
68 FIXME("no interface %s\n", debugstr_guid(riid
));
73 static HRESULT WINAPI
sti_cf_QueryInterface( IClassFactory
*iface
, REFIID riid
, LPVOID
*ppobj
)
75 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
76 IsEqualGUID(riid
, &IID_IClassFactory
))
78 IClassFactory_AddRef( iface
);
82 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
86 static ULONG WINAPI
sti_cf_AddRef( IClassFactory
*iface
)
91 static ULONG WINAPI
sti_cf_Release( IClassFactory
*iface
)
96 static HRESULT WINAPI
sti_cf_CreateInstance( IClassFactory
*iface
, LPUNKNOWN pOuter
,
97 REFIID riid
, LPVOID
*ppobj
)
99 sti_cf
*This
= impl_from_IClassFactory( iface
);
103 TRACE("%p %s %p\n", pOuter
, debugstr_guid(riid
), ppobj
);
107 r
= This
->pfnCreateInstance( riid
, pOuter
, (LPVOID
*)&punk
);
111 r
= IUnknown_QueryInterface( punk
, riid
, ppobj
);
115 IUnknown_Release( punk
);
119 static HRESULT WINAPI
sti_cf_LockServer( IClassFactory
*iface
, BOOL dolock
)
121 FIXME("(%p)->(%d)\n", iface
, dolock
);
125 static const struct IClassFactoryVtbl sti_cf_vtbl
=
127 sti_cf_QueryInterface
,
130 sti_cf_CreateInstance
,
134 static sti_cf the_sti_cf
= { { &sti_cf_vtbl
}, sti_create
};
136 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
138 TRACE("(0x%p, %ld, %p)\n",hInstDLL
,fdwReason
,lpvReserved
);
140 return STI_DllMain(hInstDLL
, fdwReason
, lpvReserved
);
143 /******************************************************************************
144 * DllGetClassObject (STI.@)
146 HRESULT WINAPI
DllGetClassObject( REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
148 IClassFactory
*cf
= NULL
;
150 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
152 if (IsEqualGUID( rclsid
, &CLSID_Sti
))
154 cf
= &the_sti_cf
.IClassFactory_iface
;
158 return IClassFactory_QueryInterface( cf
, iid
, ppv
);
159 return STI_DllGetClassObject( rclsid
, iid
, ppv
);
162 /***********************************************************************
163 * DllRegisterServer (STI.@)
165 HRESULT WINAPI
DllRegisterServer(void)
167 return STI_DllRegisterServer();
170 /***********************************************************************
171 * DllUnRegisterServer (STI.@)
173 HRESULT WINAPI
DllUnregisterServer(void)
175 return STI_DllUnregisterServer();