// Declare an HRESULT and a pointer to the clsVBTestClass interface
// Now we will intilize COM
hr = CoInitialize(0);
// Use the SUCCEEDED macro and see if we can get a pointer
// to the interface
hr = CoCreateInstance( CLSID_clsVBTestClass,
// If we succeeded then call the CountStringLength method,
// if it failed then display an appropriate message to the user.
_bstr_t bstrValue("Hello World");
hr = IVBTestClass->CountStringLength(bstrValue, &ReturnValue);
cout << "The string is: " << ReturnValue << " characters in length." << endl;
hr = IVBTestClass->Release();
// Something went wrong
cout << "CoCreateInstance Failed." << endl;
// Uninitialize COM
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 article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here