4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2003 Mike McCormack
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
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
37 extern HRESULT
HTMLDocument_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
39 /* For the moment, do nothing here. */
40 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
43 case DLL_PROCESS_ATTACH
:
44 DisableThreadLibraryCalls(hInstDLL
);
46 case DLL_PROCESS_DETACH
:
52 /******************************************************************************
56 IClassFactory ITF_IClassFactory
;
59 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
62 struct object_creation_info
66 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
69 static const struct object_creation_info object_creation
[] =
71 { &CLSID_HTMLDocument
, "HTMLDocument", HTMLDocument_create
},
75 HTMLCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
77 ICOM_THIS(IClassFactoryImpl
,iface
);
79 if (IsEqualGUID(riid
, &IID_IUnknown
)
80 || IsEqualGUID(riid
, &IID_IClassFactory
))
82 IClassFactory_AddRef(iface
);
87 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
91 static ULONG WINAPI
HTMLCF_AddRef(LPCLASSFACTORY iface
) {
92 ICOM_THIS(IClassFactoryImpl
,iface
);
96 static ULONG WINAPI
HTMLCF_Release(LPCLASSFACTORY iface
) {
97 ICOM_THIS(IClassFactoryImpl
,iface
);
99 ULONG ref
= --This
->ref
;
102 HeapFree(GetProcessHeap(), 0, This
);
108 static HRESULT WINAPI
HTMLCF_CreateInstance(LPCLASSFACTORY iface
, LPUNKNOWN pOuter
,
109 REFIID riid
, LPVOID
*ppobj
) {
110 ICOM_THIS(IClassFactoryImpl
,iface
);
114 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
116 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
121 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
126 IUnknown_Release(punk
);
130 static HRESULT WINAPI
HTMLCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
131 ICOM_THIS(IClassFactoryImpl
,iface
);
132 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
136 static ICOM_VTABLE(IClassFactory
) HTMLCF_Vtbl
=
138 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
139 HTMLCF_QueryInterface
,
142 HTMLCF_CreateInstance
,
147 HRESULT WINAPI
MSHTML_DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
150 IClassFactoryImpl
*factory
;
152 TRACE("%s %s %p\n",debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
154 if ( !IsEqualGUID( &IID_IClassFactory
, iid
)
155 && ! IsEqualGUID( &IID_IUnknown
, iid
) )
156 return E_NOINTERFACE
;
158 for (i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++)
160 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
164 if (i
== sizeof(object_creation
)/sizeof(object_creation
[0]))
166 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
167 return CLASS_E_CLASSNOTAVAILABLE
;
170 TRACE("Creating a class factory for %s\n",object_creation
[i
].szClassName
);
172 factory
= HeapAlloc(GetProcessHeap(), 0, sizeof(*factory
));
173 if (factory
== NULL
) return E_OUTOFMEMORY
;
175 factory
->ITF_IClassFactory
.lpVtbl
= &HTMLCF_Vtbl
;
178 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
180 *ppv
= &(factory
->ITF_IClassFactory
);
182 TRACE("(%p) <- %p\n", ppv
, &(factory
->ITF_IClassFactory
) );
187 HRESULT WINAPI
MSHTML_DllCanUnloadNow(void)
193 /* appears to have the same prototype as WinMain */
194 INT WINAPI
RunHTMLApplication( HINSTANCE hinst
, HINSTANCE hPrevInst
,
195 LPCSTR szCmdLine
, INT nCmdShow
)
197 FIXME("%p %p %s %d\n", hinst
, hPrevInst
, debugstr_a(szCmdLine
), nCmdShow
);