Re: ActiveX c# Array
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Thu, 4 May 2006 12:32:11 +0200
<mitch@xxxxxxxxxxxxxxxxxx> wrote in message
news:1146730449.067529.54110@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| Is this really as hard as it seems. I've been truly suprised by the
| lack of any information/suggestions about this. It should be so simple.
|
| In c# I have:
|
| double [] data = {1.0,2.0,3.0,4.0};
|
| I need to pas this array to an ActiveX control which I have written in
| Visual Studio 6 using the ActiveX wizard.
|
| So I have full control over both sets of source code. How can I Add a
| method to the ActiveX control which I can call from the c# code to pass
| the array.
|
| I've done this countless times with MFC c++ using SAFEARRYs and
| SAEFARRAYs in a VARIANT. But I cannot get this to work from c#. Has
| anyone ever done it?
|
| Any help greatly appreciated,
| Mitch.
|
Declare your method taking a SAFEARRAY of double in IDL.
HRESULT PassDoubleArray([in] SAFEARRAY(double) arr);
implement like:
STDMETHODIMP CTest::PassDoubleArray(SAFEARRAY * arr)
{
double* temp;
SafeArrayAccessData(arr, (void**)&temp);
long ubound;
SafeArrayGetUBound(arr, 1, &ubound);
for(int i = 0; i <= ubound; i++)
// use array data
..
SafeArrayUnaccessData(arr);
return S_OK;
}
and call it from C# like this:
double[] darr = new double[5] {1.1, 2.2, 3.3, 4.44, 5.2356};
obj.PassDoubleArray(darr);
Willy.
.
- Follow-Ups:
- Re: ActiveX c# Array
- From: mitch
- Re: ActiveX c# Array
- References:
- ActiveX c# Array
- From: mitch
- ActiveX c# Array
- Prev by Date: Re: how to set text back color for rich text box
- Next by Date: Re: Fill a DataSet with DataTable questions?
- Previous by thread: ActiveX c# Array
- Next by thread: Re: ActiveX c# Array
- Index(es):
Relevant Pages
|