|
#include <iostream.h>
#include <comdef.h>
#include "vbTestCOM.h"
void main()
{
// Declare an HRESULT and a pointer to the clsVBTestClass interface
HRESULT hr;
_clsVBTestClass *IVBTestClass;
// Now we will intilize COM
hr = CoInitialize(0);
// Use the SUCCEEDED macro and see if we can get a pointer
// to the interface
if(SUCCEEDED(hr))
{
hr = CoCreateInstance( CLSID_clsVBTestClass,
NULL, CLSCTX_INPROC_SERVER,
IID__clsVBTestClass,
(void**) &IVBTestClass);
// If we succeeded then call the CountStringLength method,
// if it failed then display an appropriate message to the user.
if(SUCCEEDED(hr))
{
long ReturnValue;
_bstr_t bstrValue("Hello World");
hr = IVBTestClass->CountStringLength(bstrValue, &ReturnValue);
cout << "The string is: " << ReturnValue << " characters in length." << endl;
hr = IVBTestClass->Release();
}
else
{
// Something went wrong
cout << "CoCreateInstance Failed." << endl;
}
}
// Uninitialize COM
CoUninitialize();
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.