Return using SafeArray

xiaoxiao2021-03-06  40

I met someone asking SafeArray before, I just tested how I was interested in how the COM component returned in VB Script.

IDE is used by VC7.1

Starting almost, establishing an engineering, establishing a COM object, establishing a method:

Interface definition:

[ID (2), Helpstring ("Method getArray")] HRESULT GETARRAY1 ([OUT, RETVAL] VARIANT * V);

Method Implementation: STDMETHODIMP CATL3 :: GetArray1 (Variant * Pvavariant) {std :: vector vct; vct.push_back (11.4); vct.push_back (12.4); vct.push_back (14.4); ccomsafeArray samatrix; For (int i = 0; i

Note that in the VBS or other script environments, you have to get the returning array parameters, and the types in the array are Variant Types.

VBS test script DIM V4

CNX4.Add 1, 2

v4 = cnxn4.GetArray1 ()

DIM X

For x = lbound (v4) to Ubound (V4) MSGBOX V4 (X) Next

转载请注明原文地址:https://www.9cbs.com/read-85800.html

New Post(0)