Need help with HEC-RAS
Hello
I am trying to run a COM application known as HEC-RAS from an unmanaged C++ program in Visual Studio. Classes have been added to the project by adding new MFC classes from a TypeLib. CoInitialize() has been called and interface has been created successfully. One particular method in one of the classes CHECRASControll er has the following signature in C++.
In another project we used a mixture of VB and C++ and successfully called the above function, I found that the return parameter msg() is an array of 3 strings.
In C++ I wrote
I called the function as
hec.Compute_Cur rentPlan(&pl, &psa);
This causes an internal error, I also tried creating the SAFEARRAY with VT_NULL or VT_EMPTY as the element types by
Again no success. I will appreciate any help as I don’t have experience with COM objects.
Thanks in advance
Hello
I am trying to run a COM application known as HEC-RAS from an unmanaged C++ program in Visual Studio. Classes have been added to the project by adding new MFC classes from a TypeLib. CoInitialize() has been called and interface has been created successfully. One particular method in one of the classes CHECRASControll er has the following signature in C++.
Code:
BOOL Compute_CurrentPlan(long * nmsg, SAFEARRAY * * msg); Using Object Browser this function is Function Compute_CurrentPlan(nmsg As Long, msg() As String) As Boolean.
In C++ I wrote
Code:
long pl; SAFEARRAYBOUND rgsabound[1]; rgsabound[0].lLbound = 1; // lower bound for indexing, in VB it would have been 1 rgsabound[0].cElements = 3; // from vb runs i found that 3 strings will be returned //SAFEARRAY *psa = SafeArrayCreate(VT_VARIANT, 1, rgsabound); SAFEARRAY *psa = SafeArrayCreate(VT_BSTR, 1, rgsabound); psa->fFeatures = FADF_BSTR | FADF_AUTO; // | FADF_FIXEDSIZE;
hec.Compute_Cur rentPlan(&pl, &psa);
This causes an internal error, I also tried creating the SAFEARRAY with VT_NULL or VT_EMPTY as the element types by
Code:
/* trying to see whether I can create it as VT_EMPTY or VT_NULL SAFEARRAYBOUND rgsabound[1]; rgsabound[0].lLbound = 1; // lower bound for indexing, in VB it would have been 1 rgsabound[0].cElements = 1; // from vb runs i found that 3 strings will be returned SAFEARRAY *psa; psa = SafeArrayCreateEx(VT_EMPTY, 1, rgsabound, NULL); // VT_NULL */
Thanks in advance
Comment