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
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msimtf
);
39 static HINSTANCE msimtf_instance
;
41 static HRESULT
CActiveIMM_Create(IUnknown
*outer
, REFIID riid
, void **ppv
)
43 FIXME("(%p %s %p)\n", outer
, debugstr_guid(riid
), ppv
);
47 /******************************************************************
50 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
54 case DLL_WINE_PREATTACH
:
55 return FALSE
; /* prefer native version */
56 case DLL_PROCESS_ATTACH
:
57 msimtf_instance
= hInstDLL
;
58 DisableThreadLibraryCalls(hInstDLL
);
60 case DLL_PROCESS_DETACH
:
67 const IClassFactoryVtbl
*lpClassFactoryVtbl
;
69 HRESULT (*cf
)(IUnknown
*,REFIID
,void**);
72 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
,
73 REFIID riid
, void **ppv
)
77 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
78 TRACE("(IID_IUnknown %p)\n", ppv
);
80 }else if(IsEqualGUID(&IID_IClassFactory
, riid
)) {
81 TRACE("IID_IClassFactory %p)\n", ppv
);
86 IUnknown_AddRef((IUnknown
*)*ppv
);
90 FIXME("(%s %p)\n", debugstr_guid(riid
), ppv
);
94 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
99 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
104 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
,
105 IUnknown
*pOuter
, REFIID riid
, void **ppv
)
107 ClassFactory
*This
= (ClassFactory
*)iface
;
108 return This
->cf(pOuter
, riid
, ppv
);
111 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
113 FIXME("(%d)\n", dolock
);
117 static const IClassFactoryVtbl ClassFactoryVtbl
= {
118 ClassFactory_QueryInterface
,
120 ClassFactory_Release
,
121 ClassFactory_CreateInstance
,
122 ClassFactory_LockServer
125 /******************************************************************
126 * DllGetClassObject (msimtf.@)
128 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
130 if(IsEqualGUID(&CLSID_CActiveIMM
, rclsid
)) {
131 static ClassFactory cf
= {
136 TRACE("CLSID_CActiveIMM\n");
138 return IClassFactory_QueryInterface((IClassFactory
*)&cf
, riid
, ppv
);
141 FIXME("(%s %s %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
142 return CLASS_E_CLASSNOTAVAILABLE
;
145 /******************************************************************
146 * DllCanUnloadNow (msimtf.@)
148 HRESULT WINAPI
DllCanUnloadNow(void)
154 #define INF_SET_CLSID(clsid) \
157 static CHAR name[] = "CLSID_" #clsid; \
159 pse[i].pszName = name; \
160 clsids[i++] = &CLSID_ ## clsid; \
163 static HRESULT
register_server(BOOL doregister
)
167 HRESULT (WINAPI
*pRegInstall
)(HMODULE hm
, LPCSTR pszSection
, const STRTABLEA
* pstTable
);
170 static CLSID
const *clsids
[34];
173 static const WCHAR wszAdvpack
[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
175 INF_SET_CLSID(CActiveIMM
);
177 for(i
= 0; i
< sizeof(pse
)/sizeof(pse
[0]); i
++) {
178 pse
[i
].pszValue
= HeapAlloc(GetProcessHeap(), 0, 39);
179 sprintf(pse
[i
].pszValue
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
180 clsids
[i
]->Data1
, clsids
[i
]->Data2
, clsids
[i
]->Data3
, clsids
[i
]->Data4
[0],
181 clsids
[i
]->Data4
[1], clsids
[i
]->Data4
[2], clsids
[i
]->Data4
[3], clsids
[i
]->Data4
[4],
182 clsids
[i
]->Data4
[5], clsids
[i
]->Data4
[6], clsids
[i
]->Data4
[7]);
185 strtable
.cEntries
= sizeof(pse
)/sizeof(pse
[0]);
188 hAdvpack
= LoadLibraryW(wszAdvpack
);
189 pRegInstall
= (void *)GetProcAddress(hAdvpack
, "RegInstall");
191 hres
= pRegInstall(msimtf_instance
, doregister
? "RegisterDll" : "UnregisterDll", &strtable
);
193 for(i
=0; i
< sizeof(pse
)/sizeof(pse
[0]); i
++)
194 HeapFree(GetProcessHeap(), 0, pse
[i
].pszValue
);
201 /***********************************************************************
202 * DllRegisterServer (msimtf.@)
204 HRESULT WINAPI
DllRegisterServer(void)
206 return register_server(TRUE
);
209 /***********************************************************************
210 * DllUnregisterServer (msimtf.@)
212 HRESULT WINAPI
DllUnregisterServer(void)
214 return register_server(FALSE
);