Added stub for AtlModuleUpdateRegistryFromResourceD.
[wine.git] / dlls / atl / atl_main.c
blob4ba2aa39f4f006965c122a382c85de9f2b91c875
1 /*
2 * Implementation of Active Template Library (atl.dll)
4 * Copyright 2004 Aric Stewart for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <stdarg.h>
22 #include <stdio.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winerror.h"
27 #include "winuser.h"
28 #include "wine/debug.h"
29 #include "objbase.h"
30 #include "objidl.h"
31 #include "ole2.h"
32 #include "atlbase.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(atl);
36 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
38 TRACE("(0x%p, %ld, %p)\n",hinstDLL,fdwReason,lpvReserved);
40 if (fdwReason == DLL_PROCESS_ATTACH) DisableThreadLibraryCalls(hinstDLL);
41 return TRUE;
44 HRESULT WINAPI AtlModuleInit(_ATL_MODULEA* pM, _ATL_OBJMAP_ENTRYA* p, HINSTANCE h)
46 INT i;
48 FIXME("SEMI-STUB (%p %p %p)\n",pM,p,h);
50 memset(pM,0,sizeof(_ATL_MODULEA));
51 pM->cbSize = sizeof(_ATL_MODULEA);
52 pM->m_hInst = h;
53 pM->m_hInstResource = h;
54 pM->m_hInstTypeLib = h;
55 pM->m_pObjMap = p;
56 pM->m_hHeap = GetProcessHeap();
58 /* call mains */
59 i = 0;
60 while (pM->m_pObjMap[i].pclsid != NULL)
62 TRACE("Initializing object %i\n",i);
63 p[i].pfnObjectMain(TRUE);
64 i++;
67 return S_OK;
70 HRESULT WINAPI AtlModuleTerm(_ATL_MODULEA* pM)
72 HeapFree(GetProcessHeap(), 0, pM);
73 return S_OK;
76 HRESULT WINAPI AtlModuleRegisterClassObjects(_ATL_MODULEA *pM, DWORD dwClsContext,
77 DWORD dwFlags)
79 HRESULT hRes = S_OK;
80 int i=0;
82 TRACE("(%p %li %li)\n",pM, dwClsContext, dwFlags);
84 if (pM == NULL)
85 return E_INVALIDARG;
87 while(pM->m_pObjMap[i].pclsid != NULL)
89 IUnknown* pUnknown;
90 _ATL_OBJMAP_ENTRYA *obj = &(pM->m_pObjMap[i]);
91 HRESULT rc;
93 TRACE("Registering object %i\n",i);
94 if (obj->pfnGetClassObject)
96 rc = obj->pfnGetClassObject(obj->pfnCreateInstance, &IID_IUnknown,
97 (LPVOID*)&pUnknown);
98 if (SUCCEEDED (rc) )
100 CoRegisterClassObject(obj->pclsid, pUnknown, dwClsContext,
101 dwFlags, &obj->dwRegister);
102 if (pUnknown)
103 IUnknown_Release(pUnknown);
106 i++;
109 return hRes;
112 HRESULT WINAPI AtlInternalQueryInterface(LPVOID this, const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, LPVOID* ppvObject)
114 int i = 0;
115 HRESULT rc = E_NOINTERFACE;
116 TRACE("(%p, %p, %p, %p)\n",this, pEntries, iid, ppvObject);
118 if (IsEqualGUID(iid,&IID_IUnknown))
120 TRACE("Returning IUnknown\n");
121 *ppvObject = this;
122 IUnknown_AddRef((IUnknown*)this);
123 return S_OK;
126 while (pEntries[i].pFunc != 0)
128 TRACE("Trying entry %i (%p %li %p)\n",i,pEntries[i].piid,
129 pEntries[i].dw, pEntries[i].pFunc);
131 if (pEntries[i].piid && IsEqualGUID(iid,pEntries[i].piid))
133 TRACE("MATCH\n");
134 if (pEntries[i].pFunc == (_ATL_CREATORARGFUNC*)1)
136 TRACE("Offset\n");
137 *ppvObject = ((LPSTR)this+pEntries[i].dw);
138 IUnknown_AddRef((IUnknown*)this);
139 rc = S_OK;
141 else
143 TRACE("Function\n");
144 rc = pEntries[i].pFunc(this, iid, ppvObject,0);
146 break;
148 i++;
150 TRACE("Done returning (0x%lx)\n",rc);
151 return rc;
154 /***********************************************************************
155 * AtlModuleUpdateRegistryFromResourceD [ATL.@]
158 HRESULT WINAPI AtlModuleUpdateRegistryFromResourceD(_ATL_MODULEW* pM, LPCOLESTR lpszRes,
159 BOOL bRegister, /* struct _ATL_REGMAP_ENTRY* */ void* pMapEntries, /* IRegistrar* */ void* pReg)
161 HINSTANCE hInst = pM->m_hInst;
162 /* everything inside this function below this point
163 * should go into atl71.AtlUpdateRegistryFromResourceD
165 WCHAR module_name[MAX_PATH];
167 GetModuleFileNameW(hInst, module_name, MAX_PATH);
169 FIXME("stub %p (%s), %s, %d, %p, %p\n", hInst, debugstr_w(module_name),
170 debugstr_w(lpszRes), bRegister, pMapEntries, pReg);
172 return S_OK;