variant

Sending and receiving arrays over COM

≯℡__Kan透↙ 提交于 2019-12-12 09:52:37
问题 What is the right way to receive and send arrays over COM? Here's my attempt so far: a safearray of doubles wrapped in a variant. //takes variant holding safearray of doubles //returns a similar variant having multipled every element by 2 STDMETHODIMP MyComClass::safearraytimestwo(VARIANT in, VARIANT* out) { CComSafeArray<double> sa_in; sa_in.Attach(*in.pparray); ULONG size = sa_in.GetCount(); CComSafeArray<double> *out_sa = new CComSafeArray<double>(size); for (long i=0;i<size;i++) out_sa-

How to loop thru and output values of a variant array object in Php

☆樱花仙子☆ 提交于 2019-12-12 06:38:13
问题 In my Php code I have an array object $myArrayIbject that I want to get its values. I know it is not a one dimensional array. That's what I know for sure. When I run echo gettype($myArrayIbject); It returns Object. When I run echo count($myArrayIbject); It returns 1632. When I run var_dump( $myArrayIbject); It returns object(variant)#3(0){ } When I run variant_get_type($myArrayIbject) It returns 8209. The other thing I have observed is that from $myArrayIbject[0] all the way to $myArrayIbject

Invalid variant type error Delphi 2010

扶醉桌前 提交于 2019-12-12 02:37:23
问题 // interface iccItem = class ID : String; DATA : Variant; constructor Create( _id : String; _data : Variant); end; iccDynamicObject = class private FItems : TList; function locate( _id : String) : iccItem; public constructor Create(); destructor Destroy(); override; public procedure define( _id : String; _dta : Variant); //function get( _ndx : DWORD) : Variant; overload;// link to original data function get( _id : String) : Variant; overload; public property Items[_id : String] : Variant read

Marshaling Delphi 5 OleVariant to C#

二次信任 提交于 2019-12-12 02:33:37
问题 I'm trying to use some legacy Delphi 5 DLLs from C# (2.0/3.5). Some of the exported functions are declared as such: function SimpleExport: OleVariant; stdcall; function BiDirectionalExport(X: OleVariant; var Y: OleVariant): OleVariant; stdcall; I wish to set these up as delegates using Marshal.GetDelegateForFunctionPointer, but I'm having trouble getting the data Marshaled correctly. I'm using kernel32 imports of LoadLibrary and GetProcAddress, so I'm relying on GetDelegateForFunctionPointer

c++ Excel OLE automation. Setting the values of an entire cell-range 'at once'

余生颓废 提交于 2019-12-11 19:06:17
问题 IDE: Embarcadero XE5 I am attempting to improve the performance(speed) of an 'export to excel' procedure. The procedure contains way too many OLE function calls and property read/write calls, hence the poor performance. At present, a grid(2D array) is exported to excel by stepping through each cell in the grid and setting it's value. I'm trying to export the entire grid into a excel cell-range at once, but failing in my attempts. Now for Embarcadero Delphi-users this seems to be a trivial

Invalid Variant Operation when comparing an OleVariant to UnAssigned

南笙酒味 提交于 2019-12-11 18:38:42
问题 This is my code: **if** FWordApp = UnAssigned **then** FWordApp := CreateOleObject('Word.Application') ; Result := FWordApp; The above sits in a GETter for a property of type OleVariant. The first time, it goes through fine, compares TRUE to Unassigned. However, the same isn't true the second time, where comparing to UnAssigned gives me an Invalid Variant Operation error. 回答1: As the error message is telling you, you are not allowed to compare Unassigned against a COM object in the context of

DISPID_VALUE and varargs weird behaviour

三世轮回 提交于 2019-12-11 17:56:36
问题 I am getting really strange behaviour mixing DISPID_VALUE and varargs in IDL/C++/VBA. I have the following definitions in my IDL file [ uuid(78fc63e0-fdb5-11e1-a21f-0800200c9a66), dual ] interface IPyObj : IDispatch { // ... [propget, id(DISPID_VALUE)] HRESULT Item( [in] VARIANT* Key, [out, retval] VARIANT* Result ); // ... }; // ... [entry("PyTuple"), helpstring("Builds a Python tuple object"), vararg] HRESULT __stdcall PyTuple( [in] SAFEARRAY(VARIANT)* Elements, [out, retval] VARIANT*

Pass ListObject to array. type variable String error

谁说我不能喝 提交于 2019-12-11 15:37:37
问题 The idea is passing the complete content of a listobject.databodyrange to an array to make operations in memory and not having to access the sheets cells values repeatedly which is very time consuming. this is the code. Dim theArray As Variant theArray = mylistObject.DataBodyRange.value MsgBox (theArray(1, 1)) '= column 1 row 1 = first element It works, so far so good. but!!! since theArray is dimensioned as Variant, their elements are NOT strings, So when passing every of the values of

How to copy an element of std::variant to a variable of another variant-type

不想你离开。 提交于 2019-12-10 23:50:27
问题 This is a followup on this answer. Assume we have two types of std:variant with partly the same member types. For instance if we have struct Monday {}; struct Tuesday {}; /* ... etc. */ using WeekDay= std::variant<Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday>; using Working_Day= std::variant<Monday, Tuesday, Wednesday, Thursday, Friday>; Working_Day is a sub-type of WeekDay . Now how can we copy a variable of one type to a variable of the other type? If all type members of

Boost variant apply_visitor compilation error

倾然丶 夕夏残阳落幕 提交于 2019-12-10 16:23:57
问题 This simple example code for boost::variant and boost::apply_visitor: #include <boost/variant/recursive_variant.hpp> struct ExprFalse; struct ExprTrue; struct ExprMaybe; typedef boost::variant< ExprFalse, ExprTrue, ExprMaybe > Expression; struct ExprFalse { }; struct ExprTrue { }; struct ExprMaybe { }; struct Printer : public boost::static_visitor<> { public: Printer(std::ostream& os) : m_os(os) { } void operator()(ExprFalse const& expr) const { m_os << "False"; } void operator()(ExprTrue