// ==========================================================================
// Author: Yee Hsu
// Date: 6/2/2008
// File: ComExample.h
//
// Desc: Example COM interface file
//
// Functions can be added at the END of the file, otherwise, you
// risk changing the vtable array. COM is very sensitive in this
// area and it must not change the interface or things will break.
// ==========================================================================
// ComExample.h : Declaration of the CComExample
#pragma once
#include "resource.h" // main symbols
#include <map>
#include "Example.h"
#include "ExampleExports.h"
using namespace std;
using namespace COMEXAMPLE;
// IComExample
[
object,
uuid("E97EB728-046E-4CFA-8B65-26CF2B82EB75"),
dual, helpstring("IComExample Interface"),
pointer_default(unique)
]
__interface IComExample : IDispatch
{
[id(1), helpstring("method Init")] HRESULT Init([in] BSTR sLicense);
[id(2), helpstring("method Term")] HRESULT Term(void);
[id(3), helpstring("method ParseXmlFile")] HRESULT ParseXmlFile([in] BSTR sFile);
[id(4), helpstring("method InvokeMethod")] HRESULT InvokeMethod([in] LONG nMethodId, [in] LONG nUpdateId, [in] LONG nHistoryId, [in] BSTR sXmlInput, [out,retval] BSTR* sOutput);
};
// CComExample
[
coclass,
threading("apartment"),
support_error_info("IComExample"),
vi_progid("ExampleCOM.ComExample"),
progid("ExampleCOM.ComExample.1"),
version(1.0),
uuid("A1CE08D4-4F6A-482A-83A3-EE342CF4A64C"),
helpstring("ComExample Class")
]
class ATL_NO_VTABLE CComExample :
public IComExample
{
public:
CComExample()
{
g_pExCom = NULL;
}
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
STDMETHOD(Init)(BSTR sLicense);
STDMETHOD(Term)(void);
STDMETHOD(ParseXmlFile)(BSTR sFile);
STDMETHOD(InvokeMethod)(LONG nMethodId, LONG nUpdateId, LONG nHistoryId, BSTR sXmlInput, BSTR* sOutput);
private:
CExample* g_pExCom;
std::map<CExample::ReturnCode, CComBSTR> m_ReturnCode;
};