/* Collection of code snippets by Arne Vajhøj */
/* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) */
#ifndef TESTEX_H
#define TESTEX_H

#include <windows.h>
#include <tchar.h>

#include <atlbase.h>
#include <atlcom.h>

#include "Test_i.c"
#include "Test.h"

class ATL_NO_VTABLE CCoTest : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CCoTest, &CLSID_CoTest>, public IDispatchImpl<ITest, &IID_ITest, &LIBID_TestLibrary>
{
private:
    long m_iv;
    BSTR m_sv;
public:
    CCoTest();
    virtual ~CCoTest();
    BEGIN_COM_MAP(CCoTest)
       COM_INTERFACE_ENTRY(ITest)
       COM_INTERFACE_ENTRY2(IDispatch, ITest)
    END_COM_MAP()
    // ITest
    STDMETHODIMP Add(long a, long b, long *c);
    STDMETHODIMP Concat(BSTR a, BSTR b, BSTR *c);
    STDMETHODIMP get_IV(long *iv);
    STDMETHODIMP put_IV(long iv);
    STDMETHODIMP get_SV(BSTR *sv);
    STDMETHODIMP put_SV(BSTR sv);
    static HRESULT WINAPI UpdateRegistry(BOOL b)
    {
        return _Module.UpdateRegistryClass(CLSID_CoTest, _T("Test.CoTest.1"), _T("Test.CoTest"), 0U, THREADFLAGS_APARTMENT, b);
    }
};

#endif // TESTEX_H
