//////////////////////////////////////////////////////////////////////
//
// Module	 : vs_haskell_dlg.cpp
// Author	 : Krasimir Angelov <kr.angelov@gmail.com>
// Copyright : (c) Krasimir Angelov, All Rights Reserved
//
// Implementation of DLL Exports.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resource.h"
#include "vs_haskell_dlg.h"

class CVsHaskellDlgModule : public CAtlDllModuleT< CVsHaskellDlgModule >
{
public :
	DECLARE_LIBID(LIBID_vs_haskell_dlg)
	DECLARE_REGISTRY_APPID_RESOURCEID(IDR_VS_HASKELL_DLG, "{D721BEA5-D810-407A-BFBD-CA75BC7CA922}")
};

CVsHaskellDlgModule _AtlModule;

// DLL Entry Point
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
    return _AtlModule.DllMain(dwReason, lpReserved);
}


// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
    return _AtlModule.DllCanUnloadNow();
}


// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
}


// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
    // registers object, typelib and all interfaces in typelib
	return _AtlModule.DllRegisterServer();
}


// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
	return _AtlModule.DllUnregisterServer();
}

LPCWSTR g_pszCmdLine    = L"7.1";

// DllInstall - Adds entries to the system registry
STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine)
{
	HRESULT res;
	LPCWSTR pszOldCmdLine;

	pszOldCmdLine = g_pszCmdLine;
	g_pszCmdLine  = pszCmdLine;
    res = bInstall ? DllRegisterServer() : DllUnregisterServer();
	g_pszCmdLine  = pszOldCmdLine;

	return res;
}
