OfficeExtensionTestC lass OfficeExtensionTestC lass HRESULT hr CLSID c

 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
OfficeExtensionTestClass::OfficeExtensionTestClass()
{
HRESULT hr;
CLSID clsId;
m_pIDispTestApp = NULL;
m_pWordApp = NULL;
m_pTestApp = NULL;
m_pTestingApp = NULL;
CoInitialize(NULL);
hr = CLSIDFromProgID(L"Word.Application", &clsId);
if(FAILED(hr)) {
MessageBoxW(NULL, L"CLSIDFromProgID() failed", L"Error", MB_OK);
m_pWordApp = NULL;
}
hr = CoCreateInstance(clsId, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&m_pWordApp);
if(FAILED(hr)) {
MessageBoxW(NULL, L"Word not registered properly", L"Error", MB_OK);
m_pWordApp = NULL;
}
hr = CoCreateInstance(__uuidof(TestApplicationHelper), NULL, CLSCTX_INPROC, __uuidof(ITestApplicationHelper), (void**)&m_pTestApp);
hr = m_pTestApp->QueryInterface(IID_IDispatch, (void**)&m_pIDispTestApp);
CLSIDFromProgID(L"OfficeExtension.Extension.1", &clsId);
hr = CoCreateInstance(clsId, NULL, CLSCTX_INPROC, IID_IDispatch, (void**)&m_pTestingApp);
m_pTestComponentTag = SysAllocString(L"TestComponent");
}