mlang/tests: Fix a pointer casting warning on 64-bit.
[wine/testsucceed.git] / dlls / msimtf / main.c
blob8e24a4c4837aa9b8d6018bc65e5fcce4d8c20805
1 /*
2 * Copyright 2007 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "winreg.h"
31 #include "advpub.h"
32 #include "ole2.h"
33 #include "dimm.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msimtf);
39 extern HRESULT ActiveIMMApp_Constructor(IUnknown *punkOuter, IUnknown **ppOut);
41 static HINSTANCE msimtf_instance;
43 /******************************************************************
44 * DllMain (msimtf.@)
46 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
48 switch(fdwReason)
50 case DLL_WINE_PREATTACH:
51 return FALSE; /* prefer native version */
52 case DLL_PROCESS_ATTACH:
53 msimtf_instance = hInstDLL;
54 DisableThreadLibraryCalls(hInstDLL);
55 break;
56 case DLL_PROCESS_DETACH:
57 break;
59 return TRUE;
62 typedef struct {
63 const IClassFactoryVtbl *lpClassFactoryVtbl;
65 HRESULT (*cf)(IUnknown*,IUnknown**);
66 } ClassFactory;
68 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface,
69 REFIID riid, void **ppv)
71 *ppv = NULL;
73 if(IsEqualGUID(&IID_IUnknown, riid)) {
74 TRACE("(IID_IUnknown %p)\n", ppv);
75 *ppv = iface;
76 }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
77 TRACE("IID_IClassFactory %p)\n", ppv);
78 *ppv = iface;
81 if(*ppv) {
82 IUnknown_AddRef((IUnknown*)*ppv);
83 return S_OK;
86 FIXME("(%s %p)\n", debugstr_guid(riid), ppv);
87 return E_NOINTERFACE;
90 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
92 return 2;
95 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
97 return 1;
100 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface,
101 IUnknown *pOuter, REFIID riid, void **ppv)
103 ClassFactory *This = (ClassFactory*)iface;
104 HRESULT ret;
105 IUnknown *obj;
106 TRACE("(%p, %p, %s, %p)\n", iface, pOuter, debugstr_guid(riid), ppv);
108 ret = This->cf(pOuter, &obj);
109 if (FAILED(ret))
110 return ret;
112 ret = IUnknown_QueryInterface(obj,riid,ppv);
113 IUnknown_Release(obj);
114 return ret;
117 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
119 FIXME("(%d)\n", dolock);
120 return S_OK;
123 static const IClassFactoryVtbl ClassFactoryVtbl = {
124 ClassFactory_QueryInterface,
125 ClassFactory_AddRef,
126 ClassFactory_Release,
127 ClassFactory_CreateInstance,
128 ClassFactory_LockServer
131 /******************************************************************
132 * DllGetClassObject (msimtf.@)
134 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
136 if(IsEqualGUID(&CLSID_CActiveIMM, rclsid)) {
137 static ClassFactory cf = {
138 &ClassFactoryVtbl,
139 ActiveIMMApp_Constructor,
142 return IClassFactory_QueryInterface((IClassFactory*)&cf, riid, ppv);
145 FIXME("(%s %s %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
146 return CLASS_E_CLASSNOTAVAILABLE;
149 /******************************************************************
150 * DllCanUnloadNow (msimtf.@)
152 HRESULT WINAPI DllCanUnloadNow(void)
154 FIXME("()\n");
155 return S_FALSE;
158 #define INF_SET_CLSID(clsid) \
159 do \
161 static CHAR name[] = "CLSID_" #clsid; \
163 pse[i].pszName = name; \
164 clsids[i++] = &CLSID_ ## clsid; \
165 } while (0)
167 static HRESULT register_server(BOOL doregister)
169 HRESULT hres;
170 HMODULE hAdvpack;
171 HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
172 STRTABLEA strtable;
173 STRENTRYA pse[1];
174 static CLSID const *clsids[34];
175 unsigned int i = 0;
177 static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
179 INF_SET_CLSID(CActiveIMM);
181 for(i = 0; i < sizeof(pse)/sizeof(pse[0]); i++) {
182 pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, 39);
183 sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
184 clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
185 clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
186 clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
189 strtable.cEntries = sizeof(pse)/sizeof(pse[0]);
190 strtable.pse = pse;
192 hAdvpack = LoadLibraryW(wszAdvpack);
193 pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
195 hres = pRegInstall(msimtf_instance, doregister ? "RegisterDll" : "UnregisterDll", &strtable);
197 for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++)
198 HeapFree(GetProcessHeap(), 0, pse[i].pszValue);
200 return hres;
203 #undef INF_SET_CLSID
205 /***********************************************************************
206 * DllRegisterServer (msimtf.@)
208 HRESULT WINAPI DllRegisterServer(void)
210 return register_server(TRUE);
213 /***********************************************************************
214 * DllUnregisterServer (msimtf.@)
216 HRESULT WINAPI DllUnregisterServer(void)
218 return register_server(FALSE);