variant

How do I create a variant array of BSTR in Euphoria using EuCOM?

So far I've figured out how to pass Unicode strings, bSTRs, to and from a Euphoria DLL using a Typelib. What I can't figure out, thus far, is how to create and pass back an array of BSTRs. The code I have thus far (along with includes for EuCOM itself and parts of Win32lib): global function REALARR() sequence seq atom psa atom va...

C++ Variant

I'm in the process of creating a class that stores metadata about a particular data source. The metadata is structured in a tree, very similar to how XML is structured. The metadata values can be integer, decimal, or string values. I'm curious if there is a good way in C++ to store variant data for a situation like this. I'd like for...

COM, VARIANT containing BSTR. Who allocates?

OK, so I couldn't really think of an apropos title that summarizes this. The IPrintPipelinePropertyBag interface has the method AddProperty which aptly enough "adds a property to a property bag." http://msdn.microsoft.com/en-us/library/aa506384.aspx AddProperty( [in, string] const wchar_t *pszName, [in] const VARIANT *pVa...

How is duck typing different from the old 'variant' type and/or interfaces?

I keep seeing the phrase "duck typing" bandied about, and even ran across a code example or two. I am way too lazy busy to do my own research, can someone tell me, briefly: the difference between a 'duck type' and an old-skool 'variant type', and provide an example of where I might prefer duck typing over variant typing, and provide a...

Why can't Delphi variants hold objects?

Why can't Delphi variants hold objects? More importantly, what's the reason behind this limitation? ...

De facto list of primitive types usable in C++

If, for example, you're going to write a variant type class, you will naturally need identification of what type an instance of that class is carrying. I'm wondering if anyone knows of any official or semi-official (de-facto?) reference of all primitive datatypes one would possibly be interested in? Only primitives, and no need for abs...

Problem with SafeArray access using CComVariant

Hi, I have following block of code ///////////////////////////////////// CComVariant newVal; //pass the CComVariant and get the strings array!!! GetStrList(newVal); USES_CONVERSION; if (((newVal.vt & VT_ARRAY) == VT_ARRAY) && ((newVal.vt & VT_BSTR) == VT_BSTR)) { SAFEARRAY* paArray = newVal.parray; BSTR * str = NULL; SafeArray...

Variables in Visual Basic

What's the main problem if I don't declare the type of a variable? Like, Dim var1 versus Dim var1 as Integer. It can be anything so it should be good! ...

Delphi: Pass TObject in array of Variants

I have a procedure that expects a parameter of type TObject, something like this: MyProcedure (const AValue : TObject); I have an array of Variant that I'm looping through to call the procedure, something like this: for i:=0 to High(myArray) do MyProcedure (myArray[i]); The compiler gives an error saying: "Incompatible types:...

Access Query Error - Null & Variant Data Types - How do I fix this error?

All, This error is driving me insane. I've spent 2 hours trying to figure it out and/or work around it with no luck. Here's the error: "You tried to assign the NULL value to a variable that is not a Variant data type." Here's my SQL: SELECT tbl_budir_002.Location_Index, tbl_parent_001.NEWPARENTID INTO tbl_budir_003 FROM (tbl_budi...

Parameter type for a complex object in a COM-visible function (VB6)

Should we use object or variant? What difference does it make? ...

How can I implement variant types in the CLR/Managed C++ ?

In the .net CLR Object is the base for all class objects, but not basic types (e.g. int, float etc). How can I use basic types like Object? I.e. Like Boost.Variant? E.g. like :- object intValue( int(27) ); if (intValue is Int32) ... object varArray[3]; varArray[0] = float(3.141593); varArray[1] = int(-1005); varArray[2] = string("...

Delphi: No VarIsBoolean( )-function?

In variants.pas, there is several VarIsXXX( )-functions for type-checking a variant. There is no VarIsBoolean( ), though. What's your preferred way of checking if a variant is of type boolean? ...

Invalid Variant crash

I have a situation where I've wrapped a Native C++ DLL with C++/CLI for eventual use in C#. There are a few callback functions that are causing some issues at run time. Particularly, I get the following exception: An unhandled exception of type 'System.Runtime.InteropServices.InvalidOleVariantTypeException' occurred in ToadWra...

Using COM object from C++ that in C#.NET returns object []

I have a COM object that I'm trying to use from C++ (not .NET), and all of the example programs and manual are written assuming the use of C#.NET or VB.NET. COM is new to me so I'm a bit overwhelmed. I'm using #import on the TLB but am struggling to deal with the variants that are used as parameters. I have one particular method, that ac...

Function which returns an unknown type

class Test { public: SOMETHING DoIt(int a) { float FLOAT = 1.2; int INT = 2; char CHAR = 'a'; switch(a) { case 1: return INT; case 2: return FLOAT; case 3: return CHAR; } } }; int main(int argc, char* argv[]) { Test obj; cout<<obj.DoIt(1); return 0; } Now, using the knowledge that a = 1 implies that...

free the variant VarArray

FUNCTION SystemspartsClT.KeyFound(Key : AluCostDict.SystemspartskeyT) : BOOLEAN; VAR v : Variant; BEGIN v := VarArrayCreate([0,1], VarInteger); v[0] := Key.System; v[1] := Key.PartType; Sucess := t.Locate('System;PartType', v, []); v := NULL; Result := Sucess; END; I am using Delphi for Win32. Does thi...

How to create propput IDL method .NET interface for COM usage

I am having an issue using a .NET/ComVisible assembly in Excel/VBA. I defined several parameters as "object" in .NET so they will be translated to Variant in VBA since optional parameters in VBA need to use Variant types. The problem is when I try to use the object in Excel/VBA, I get a "Run-time error '424': Object required". I think I...

How to marshal .NET string to variant for COM call

I'm using a third-party COM library from C#. There are get/set methods that take a parameter of type VARIANT (type VT_BSTR). In the .NET wrapper, these parameters appear as type object, i.e. object getValue(); void setValue( object val ); The getValue method works ok, I perform a simple cast of the object to type string: string str ...

How to make a type safe wrapper around Variant values

I'm working with a OPC Server control that stores data tags as variant types, described by System.Runtime.InteropServices.VarEnum. These types include the following, VT_BSTR (string), VT_I2 (short) and VT_I4 (long). All these values are stored by the server as objects and then I have to cast to the correct value when I fetch them. I kn...