ICP  1
test.cpp
Go to the documentation of this file.
1 // test.cpp : Implementation of Ctest
2 
3 #include "stdafx.h"
4 #include "test.h"
5 #include "block.h"
6 #include "../instapi_lib/instapi_lib.h"
7 
8 #include "Poco/SingletonHolder.h"
9 
10 static Poco::SingletonHolder<InstAPILib> inst_api;
11 
12 
13 // Ctest
14 
15 STDMETHODIMP Ctest::InterfaceSupportsErrorInfo(REFIID riid)
16 {
17  static const IID* const arr[] =
18  {
19  &IID_Itest
20  };
21 
22  for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
23  {
24  if (InlineIsEqualGUID(*arr[i],riid))
25  return S_OK;
26  }
27  return S_FALSE;
28 }
29 
30 
31 STDMETHODIMP Ctest::setBlockValue(BSTR block_name, VARIANT block_value)
32 {
33  InstAPILib* the_api = inst_api.get();
34  try
35  {
36  return the_api->setBlockValue(block_name, block_value);
37  }
38  catch(std::exception& ex)
39  {
40  AtlReportError(GetObjectCLSID(), ex.what());
41  return E_FAIL;
42  }
43  return S_OK;
44 }
45 
46 
47 STDMETHODIMP Ctest::getBlockValue(BSTR block_name, VARIANT* block_value)
48 {
49  InstAPILib* the_api = inst_api.get();
50  try
51  {
52  return the_api->getBlockValue(block_name, block_value);
53  }
54  catch(std::exception& ex)
55  {
56  AtlReportError(GetObjectCLSID(), ex.what());
57  return E_FAIL;
58  }
59  return S_OK;
60 }
61 
62 
63 STDMETHODIMP Ctest::getBlock(BSTR name, IDispatch** block)
64 {
65  // TODO: Add your implementation code here
66  CComPtr<Cblock::Iblock> the_block;
67  the_block.CoCreateInstance(CLSID_block, 0, CLSCTX_INPROC_SERVER);
68  *block = the_block;
69  return S_OK;
70 }
71 
72 
73 STDMETHODIMP Ctest::getBlock2(BSTR name, Iblock** block)
74 {
75  // TODO: Add your implementation code here
76  CComPtr<Cblock::Iblock> the_block;
77  the_block.CoCreateInstance(CLSID_block, 0, CLSCTX_INPROC_SERVER);
78  *block = the_block;
79  return S_OK;
80 }
HRESULT InterfaceSupportsErrorInfo(REFIID riid)
Definition: test.cpp:15
HRESULT getBlockValue(BSTR block_name, VARIANT *block_value)
Definition: test.cpp:47
HRESULT setBlockValue(BSTR block_name, VARIANT block_value)
Definition: test.cpp:31
Poco::SingletonHolder< InstAPILib > inst_api
HRESULT getBlock2(BSTR name, Iblock **block)
Definition: test.cpp:73
void getBlockValue(ULONG session_id, BSTR block_name, VARIANT *block_value)
HRESULT getBlock(BSTR name, IDispatch **block)
Definition: test.cpp:63