user32: Simplify some maximized MDI child checks.
[wine/dibdrv.git] / dlls / msi / msi_main.c
blob294de714dd850aca0ee5004c3cd88a9d4940eee2
1 /*
2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2006 Mike McCormack 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #define COBJMACROS
24 #define NONAMELESSUNION
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winreg.h"
29 #include "shlwapi.h"
30 #include "msipriv.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(msi);
36 static LONG dll_count;
38 /* the UI level */
39 INSTALLUILEVEL gUILevel = INSTALLUILEVEL_BASIC;
40 HWND gUIhwnd = 0;
41 INSTALLUI_HANDLERA gUIHandlerA = NULL;
42 INSTALLUI_HANDLERW gUIHandlerW = NULL;
43 DWORD gUIFilter = 0;
44 LPVOID gUIContext = NULL;
45 WCHAR gszLogFile[MAX_PATH];
46 HINSTANCE msi_hInstance;
49 * Dll lifetime tracking declaration
51 static void LockModule(void)
53 InterlockedIncrement(&dll_count);
56 static void UnlockModule(void)
58 InterlockedDecrement(&dll_count);
61 /******************************************************************
62 * DllMain
64 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
66 switch (fdwReason)
68 case DLL_PROCESS_ATTACH:
69 msi_hInstance = hinstDLL;
70 DisableThreadLibraryCalls(hinstDLL);
71 msi_dialog_register_class();
72 break;
73 case DLL_PROCESS_DETACH:
74 msi_dialog_unregister_class();
75 msi_free_handle_table();
76 break;
78 return TRUE;
81 typedef struct tagIClassFactoryImpl
83 const IClassFactoryVtbl *lpVtbl;
84 } IClassFactoryImpl;
86 static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface,
87 REFIID riid,LPVOID *ppobj)
89 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
90 FIXME("%p %s %p\n",This,debugstr_guid(riid),ppobj);
91 return E_NOINTERFACE;
94 static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface)
96 LockModule();
97 return 2;
100 static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface)
102 UnlockModule();
103 return 1;
106 static HRESULT WINAPI MsiCF_CreateInstance(LPCLASSFACTORY iface,
107 LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
109 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
111 FIXME("%p %p %s %p\n", This, pOuter, debugstr_guid(riid), ppobj);
112 return E_FAIL;
115 static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
117 TRACE("%p %d\n", iface, dolock);
119 if (dolock)
120 LockModule();
121 else
122 UnlockModule();
124 return S_OK;
127 static const IClassFactoryVtbl MsiCF_Vtbl =
129 MsiCF_QueryInterface,
130 MsiCF_AddRef,
131 MsiCF_Release,
132 MsiCF_CreateInstance,
133 MsiCF_LockServer
136 static IClassFactoryImpl Msi_CF = { &MsiCF_Vtbl };
138 /******************************************************************
139 * DllGetClassObject [MSI.@]
141 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
143 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
145 if( IsEqualCLSID (rclsid, &CLSID_IMsiServer) ||
146 IsEqualCLSID (rclsid, &CLSID_IMsiServerMessage) ||
147 IsEqualCLSID (rclsid, &CLSID_IMsiServerX1) ||
148 IsEqualCLSID (rclsid, &CLSID_IMsiServerX2) ||
149 IsEqualCLSID (rclsid, &CLSID_IMsiServerX3) )
151 *ppv = (LPVOID) &Msi_CF;
152 return S_OK;
154 return CLASS_E_CLASSNOTAVAILABLE;
157 /******************************************************************
158 * DllGetVersion [MSI.@]
160 HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *pdvi)
162 TRACE("%p\n",pdvi);
164 if (pdvi->cbSize < sizeof(DLLVERSIONINFO))
165 return E_INVALIDARG;
167 pdvi->dwMajorVersion = MSI_MAJORVERSION;
168 pdvi->dwMinorVersion = MSI_MINORVERSION;
169 pdvi->dwBuildNumber = MSI_BUILDNUMBER;
170 pdvi->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
172 return S_OK;
175 /******************************************************************
176 * DllCanUnloadNow [MSI.@]
178 HRESULT WINAPI DllCanUnloadNow(void)
180 return dll_count == 0 ? S_OK : S_FALSE;