variant

How do I (or if I can't) use Variants on simple DLLs?

I want to expose some functionality of a internal object as a DLL - but that functionality uses variants. But I need to know: I can export a function with Variant parameters and/or return - or is better to go to an string-only representation? What is better, from language-agnostic POV (the consumer is not made with Delphi - but all wil...

OLEVariant to .Net byte[]

I have an OLEVariant disguised as a .Net object that I recieve from a client-side component over the net. I know that the contents are an array of bytes, but I don't know how to convert those contents to a native .Net byte array (byte[]). Any clues on how I can accomplish the conversion? Edit: We answered our own question. To take an Ol...

Basic code to Delphi

I'm struggling with the following: The goal is to parametrize an automation server for openoffice and I'm programming in Delphi. The piece of basic code I want to translate into Delphi code is: Dim aProps(1) As New com.sun.star.beans.PropertyValue aProps(0).Name = "FilterName" aProps(0).Value = "Text - txt - csv (StarCalc)" aProps(1)....

Marshaling Delphi 5 OleVariant to C#

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 ha...

Copying between VARIANT and _variant_t

I'm fairly certain that I can safely do: void funcA(VARIANT &V,_variant_t &vt) { vt = V; } But what about the other way around: void funcB(VARIANT &V,_variant_t &vt) { V = vt; } I've been seeing some REALLY weird behaviour in my app which I put down to COM-related threading issues. But then I got wondering if I was screwing...

How to build a SAFEARRAY of pointers to VARIANTs?

I'm trying to use a COM component with the following method: HRESULT _stdcall Run( [in] SAFEARRAY(BSTR) paramNames, [in] SAFEARRAY(VARIANT *) paramValues ); How can I create in C/C++ the paramValues array? ...

VB6 convert to VB.net Variant question

I have been tasked to convert out VB6 program to VB.NET. In my research online everyone seems to say I need to go through my code and get rid of any Variants I have. I have had pretty good luck so far, but I am having an issue in replacing this one. Private Sub lvThumbView_OLEDragDrop(Data As MSComctlLib.DataObject) Dim File As Vari...

Assign VB6 Variant into an Object

I have a VB6 application that uses a C# compiled Dll. I have been successfull in making this work by means of COM. But my problem is that I have a Variant array with String and Double data types inside it. I need to pass this array to my C# Dll, which is receiving the array as an Object. So, all I need to do is to convert the Variant arr...

Function Null for variant in Delphi 2010

where is this funtion in Delphi 2010 function Null: Variant; begin _VarNull(TVarData(Result)); end; in Delphi 6 it was in Variants ...

how to send VARIANT_bstr over COPYDATASTRUCT

hi, I need to send a VARIANT value to another application using COPYDATASTRUCT. Here is the structure i'm using to send messages. struct { int i_MsgId; VARIANT variant_Value; }Message; In my code I initialize the VARIANT to type BSTR and allocate a string as follows. Message structMessage; VariantInit(&structMessage.varian...

Creating a simple scripted 'language' - VARIANT-like value type

For a rules engine developed in C++, one of the core features is the value type. What I have so far is a bit like a COM-style VARIANT - each value knows its type. There are some rules for type conversion but it's a bit messy. I wondered if there are nice drop-in value classes I could use which solve this, without requiring me to use a w...

Is the number of types in a C++ template variant limited?

I'm trying to understand how variants are implemented, and reading: http://www.codeproject.com/KB/cpp/TTLTyplist.aspx And I'm getting the impression that I can't write a variant that takes X types; but that the template writer picks some N, and I can only have less than-N types in a variant. Is this correct? Thanks! ...

How to implement a basic Variant (& a visitor on the Variant) template in C++?

I have tried reading: http://www.boost.org/doc/libs/1_41_0/boost/variant.hpp http://www.codeproject.com/KB/cpp/TTLTyplist.aspx and chapter 3 of "Modern C++ Design" but still don't understand how variants are implemented. Can anyone paste a short example of how to define something like: class Foo { void process(Type1) { ... }; ...

How to build this c++ typelist into a variant?

Here, http://stackoverflow.com/questions/2150618/how-do-i-fix-this-c-typelist-template-compile-error we built a typelist, using the code from modern c++ design. Question is now -- how do I take this and built it into a variant class? Thanks! ...

Is there any C++ book that talks about how to implement variants?

Modern C++ design only gets me to typelists. C++ templates the complete guide brings me only to tuples. I want to learn how to _implement variants. Does any C++ book explains this? Thanks! ...

Does dispatching on a Boost variant type take linear time ?

How efficient is dispatching on a boost::variant ? If it's a switch statement, it should only take O(1) time, but as far as I know, template metaprogrammign can only generate if's, which would put boost::variant dispatchs at a runtime overhead of O(n), where n = number of types in the variant. Can anyone confirm/deny/enlighten me on th...

A simple way to convert to/from VARIANT types in C++

Are there any easy-to-use, high-level classes or libraries that let you interact with VARIANTs in Visual C++? More specifically, I'd like to convert between POD types (e.g. double, long), strings (e.g. CString), and containers (e.g. std::vector) and VARIANTs. For example: long val = 42; VARIANT var; if (ToVariant(val, var)) ... ...

What is the difference between the VarIsEmpty and VarIsEmptyParam functions

Working in Delphi7 just now, I noticed that not only a VarIsEmpty function exists, but also a VarIsEmptyParam. Since the help of Delphi does not give much explanation: VarIsEmptyParam returns true if the given variant represents an unassigned optional parameter. If the variant contains any other value, the function result is...

What's the syntax for including methods in a variant record?

I have the following record definition E3Vector3T = packed record public x: E3FloatT; y: E3FloatT; z: E3FloatT; function length: E3FloatT; function normalize: E3Vector3T; function crossProduct( const aVector: E3Vector3T ): E3Vector3T; class operator add( const aVector1, aVector2: E3Vector3...

Delphi 2010 variant to unicode problem

I am working on a DLL in Delphi 2010. It exports a procedure that receives an array of variants. I want to be able to take one of these variants, and convert it into a string, but I keep getting ????? I cannot change the input variable - it HAS to be an array of variants. The host app that calls the DLL cannot be changed. It is written ...