-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.cpp
More file actions
53 lines (47 loc) · 1.33 KB
/
client.cpp
File metadata and controls
53 lines (47 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// system
#include <windows.h>
// c++
#include <cstdio>
// local
#include "com_ptr.hpp"
#include "bstr.hpp"
#include "foo.h"
using namespace std;
using namespace rap;
int main(int argc, char** argv)
{
try
{
TRACE();
THROW_IF_FAILED(CoInitialize(nullptr));
{
com_ptr<IClassFactory> fooFactory;
THROW_IF_FAILED(
CoGetClassObject(
CLSID_Foo,
CLSCTX_LOCAL_SERVER,
nullptr,
IID_IClassFactory,
(void**)&fooFactory));
com_ptr<IFoo> foo;
THROW_IF_FAILED(fooFactory->CreateInstance(nullptr, IID_IFoo, (void**)&foo));
LONG barCount = 0;
THROW_IF_FAILED(foo->getBarCount(&barCount));
TRACE_MSG("bar count : %d", barCount);
for(LONG idx = 0; idx < barCount; ++idx)
{
com_ptr<IBar> bar;
THROW_IF_FAILED(foo->getBarAt(idx, &bar));
bstr str;
THROW_IF_FAILED(bar->getString(&str));
TRACE_MSG("bar[%i] : %S", idx, str.get());
}
}
CoUninitialize();
throw nullptr;
}
catch(...)
{
TRACE_MSG("Make sure you've done the required server and proxy registration, see registerFoo.bat");
}
}