WCHAR gszLogFile[MAX_PATH];
HINSTANCE msi_hInstance;
+static LONG dll_count;
+
static const WCHAR installerW[] = {'\\','I','n','s','t','a','l','l','e','r',0};
+/**********************************************************************
+ * Dll lifetime tracking declaration
+ */
+static void LockModule(void)
+{
+ InterlockedIncrement(&dll_count);
+}
+
+static void UnlockModule(void)
+{
+ InterlockedDecrement(&dll_count);
+}
+
+
UINT WINAPI MsiOpenProductA(LPCSTR szProduct, MSIHANDLE *phProduct)
{
UINT r;
static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface)
{
+ LockModule();
return 2;
}
static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface)
{
+ UnlockModule();
return 1;
}
static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
{
- IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+ TRACE("(%p)->(%d)\n", iface, dolock);
+
+ if(dolock)
+ LockModule();
+ else
+ UnlockModule();
- FIXME("%p %d\n", This, dolock);
return S_OK;
}
*/
HRESULT WINAPI DllCanUnloadNow(void)
{
- return S_FALSE;
+ return dll_count == 0 ? S_OK : S_FALSE;
}
/***********************************************************************