Questions tagged [safearray]

145 questions
12
votes
3 answers

How to create and initialize SAFEARRAY of doubles in C++ to pass to C#

My C# method needs to be invoked from C++ Originally my C# method takes a parameter of type double[], but when calling from C++ it becomes a SAFEARRAY In C++ I need to take data from an array of doubles, and populate a SAFEARRAY. I have not found…
Chris
  • 121
  • 1
  • 1
  • 3
12
votes
3 answers

How does one return a local CComSafeArray to a LPSAFEARRAY output parameter?

I have a COM function that should return a SafeArray via a LPSAFEARRAY* out parameter. The function creates the SafeArray using ATL's CComSafeArray template class. My naive implementation uses CComSafeArray::Detach() in order to move ownership…
Motti
  • 110,860
  • 49
  • 189
  • 262
11
votes
2 answers

How to iterate through SAFEARRAY **

how to iterate through C++ safearray pointer to pointer and access its elements. I tried to replicate the solution posted by Lim Bio Liong http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/022dba14-9abf-4872-9f43-f4fc05bd2602 but the…
TrustyCoder
  • 4,749
  • 10
  • 66
  • 119
9
votes
1 answer

Release SAFEARRAY from c++ DLL and c#

I have a c++ function that gets data and I called it from c#. The function gets a pointer to SAFEARRAY and poplate it with strings (using SysAllocString) Everything is ok, but the program is leaking memory. I did a little search and found that if I…
SharonL
  • 101
  • 1
  • 3
9
votes
1 answer

Is it possible to marshal ref parameters in SAFEARRAY

Here is my C# server method: public void Exec(out int status, string output) { status = 3; Console.WriteLine("Exec({0}, ...)", status); output = string.Format("Hello from .NET {0}", DateTime.Now); Console.WriteLine("Exec(...,…
8
votes
3 answers

How to display values from a VARIANT with a SAFEARRAY of BSTRs

I am working on a COM Object library with function that returns a VARIANT with a SAFEARRAY of BSTRs. How can I display the values from this VARIANT instance and save it inside a TStringList? I tried searching the net with no clear answer. I tried…
Heb
  • 111
  • 2
  • 6
7
votes
2 answers

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?
Serge Weinstock
  • 1,235
  • 3
  • 12
  • 20
6
votes
1 answer

Passing a Safearray of custom types from C++ to C#

how can one use a Safearray to pass an array of custom types (a class containing only properties) from C++ to C#? Is using the VT_RECORD type the right way to do it? I am trying in the following way, but SafeArrayPutElement returns an error when…
Stefano Ricciardi
  • 2,923
  • 3
  • 33
  • 40
6
votes
2 answers

COM SAFEARRAY of GUID's returned from C++ to C#

I'm currently running into an issue of needing to pass a SAFEARRAY(GUID) as a return value from C++ to C#. Currently the C# side is using an Interop dll generated from Tlbimp.exe (Type Library Importer). The IDL is: HRESULT GetGuids( …
Steve
  • 976
  • 12
  • 12
6
votes
3 answers

Return SAFEARRAY of custom interface types to VB6 through COM

Is it possible to return an array of defined interface objects from a C++ COM function (VC6) to a VB6 client? I've scoured the web and haven't been able to come across anything that describes what I need to do. I've seen a lot of passing BSTR and…
Jack Smith
  • 713
  • 3
  • 9
  • 19
6
votes
2 answers

Delphi OleVariant to array of string from COM Library

I have Delphi 2006 client application. This client recieves an Olevariant type data from COM server. The function is: procedure OnLimitsChanged(var SymbolsChanged: {??PSafeArray}OleVariant); This function returns an array of string. I can´t read…
EFD
  • 61
  • 1
  • 2
6
votes
1 answer

How to pass SAFEARRAY to COM object through IDispatch?

i am trying to call a method of COM object, where one of the documented parameters is an "array of bytes". The actual declartion depends on the per-language documentation you're looking at: in C# language: byte[] TransformFinalBlock( byte[]…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
5
votes
0 answers

How does VBA determine the lifetime of non-IUnknown reference types?

I'm trying to understand what dictates the lifetime of different bits of data; how the VBA interpreter knows it is safe to release the associated memory of a given variable. Here's what I've found so far: Value types Simple value types use scope to…
Greedo
  • 4,967
  • 2
  • 30
  • 78
5
votes
1 answer

SAFEARRAY on linux

I'm using a proprietary library on linux that uses SAFEARRAY type in a callback function: HRESULT Write(SAFEARRAY *Data) SAFEARRAY is defined in a header file as typedef void SAFEARRAY. I must define a callback function that will get the data (eg.…
microo8
  • 3,568
  • 5
  • 37
  • 67
5
votes
2 answers

Pointers to arrays stored as collection/dictionary items VBA

With variant arrays where each element is a double array I am able to do the following: Public Declare PtrSafe Sub CopyMemoryArray Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination() As Any, ByRef Source As Any, ByVal Length As Long) Sub…
drgs
  • 375
  • 2
  • 8
1
2 3
9 10