Note:
- Attempting to invoke a method of an interface, of which the return type is
_variant_t
Code:
_variant_t resultsDataString;
_bstr_t simObjectNames;
simObjectNames = SysAllocString (L"TEST example 3");
resultsDataString = pis8->GetSimObject (simObjectNames);
inline function illustrated below, contained in .tli FILE:
inline _variant_t IS8Simulation::GetSimObject ( _bstr_t Name ) {
VARIANT _result;
VariantInit(&_result);
HRESULT _hr = get_SimObject(Name, &_result);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _variant_t(_result, false);
}
Note:
resultsDataString
is ofstruct
tagVARIANT
:VARTYPE vt
is 9 (unsigned short)IDispatch
IDispatch interface pointer
Question
- How can I then convert or extract the value?
- Possible using VariantChangeType?
- Another way?
Edit:
Note:
Looking to transform the following, Visual Basic code to Visual C++
MFC or ATL, if need be
Ideally, pure C++
Visual basic equivalent:
Public example1, example2 As SIMUL8.S8SimObject
Dim numberOfexamples As Variant
Dim resultString As Variant
Set example1 = MySimul8.SimObject("Example 1")
Set example2 = MySimul8.SimObject("Example 2")
numberOfexamples = example1.CountContents + example2.CountContents
resultString = CStr(numberOfexamples) & "*"
Edit:
- Thanks for all your help - much appreciated :)