|
-
January 25th, 2002, 08:27 AM
#1
returning array and VARIANT problem
I am attempting to use an ActiveX control and I need to access the return from a function defined in the control wrapper class as :
VARIANT C_Protocol::GET_WORKTABLE_DATA(BSTR* sWorktableFile)
I have a VB example that calls it with
Dim vWorkTable As Variant
With AtiveXCtrl
vWorkTable = .THE_FUNCTION (...)
What I want to know is what type do I equate the call to in C++. It is defined as a
variant/string (1 to 12, 1 to 2)
in VB.
Thanks,
Paul
-
January 25th, 2002, 02:29 PM
#2
Re: returning array and VARIANT problem
You can use CString.
See my example at
http://atcsoft.freeservers.com/thele...TL/sample2.htm
Please rate the article if it is of any use to you. This encourages me to reply more and more and more.
-
January 29th, 2002, 03:35 AM
#3
Re: returning array and VARIANT problem
Thanks for the reply.
As far as I can tell this is not quite what I was asking for. I am writing a C++ function that calls up a VB ActiveX control. The control returns an array. I need to know how IO can get access to this array from my C++ code.
Thanks again,
Paul
-
January 29th, 2002, 03:58 AM
#4
Re: returning array and VARIANT problem
Have a look at the vt member of the VARIANT, which will tell you what type it is. If it's an array (VT_ARRAY) then Automation provides a load of SafeArrayXXX functions to manipulate the underlying SAFEARRAY object (the parray member of the VARIANT). For example:VARIANT v = <function call>
if (v.vt & VT_ARRAY)
{
// get the dimensions of the array
UINT nDim = SafeArrayGetDim(v.parray);
// you can get the size of the array using
// SafeArrayGetLBound and SafeArrayGetUBound
void* pData;
HRESULT hr = SafeArrayAccessData(v.parray,&pData);
if (SUCCEEDED(hr))
{
// pData now points to the array data
SafeArrayUnaccessData(v.parray);
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|