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...
Hi guys,
This most likely has a very simple answer, but I can't figure it out.
I'm trying to refactor some code that looks like this:
SAFEARRAY* psa;
long* count;
HRESULT hr = pSomeInterface->ListSomething(&psa, &count);
if (SUCCEEDED(hr))
{
CComSafeArray<BSTR> sa;
if (*count > 0)
{
sa.Attach(psa);
}
}
// perf...
Hi,
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 trying to fill the safearray the reference to the array of classes gets to the managed ...
We have a COM component who’s implementation and interface definition exist in managed code but is driven by a native component. The managed component is returning a SafeArray back to the native code via the following method declaration.
interface IExample {
<return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_UNKN...
I have a .NET assembly. It happens to be written in C++/CLI. I am exposing a few objects via COM. Everything is working fine, but I cannot for the life of me figure out how to return an array of my own objects from a method. Every time I do, I get a type mismatch error at runtime. I can return an array of ints or strings just fine.
...
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<T>::Detach() in order to move ownership from the local variable to the output parameter:
void foo(LPSAFEARRAY* psa)
{
CComSafeA...
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?
...
Hello!
There is the function GetLinksFromPage. She have created a links array, then I wanna pass that array to COM-object (only URLs), thus I have to convert CAtlArray< CComPtr< IDispatch> > to CComSafeArray< BSTR>. How I can do it ?
HRESULT myclass::GetLinksFromPage( const CComPtr<IHTMLDocument2>& pDoc, CAtlArray<CComPtr<IDispatch> > &...
I have the following code in C++ which I need to be able to call from C#:
struct Inner
{
double data1;
double data2;
};
struct Outer
{
double data3;
SAFEARRAY innerData;
};
int WINAPI ProcessData (Outer& outer )
{
...
}
I tried the following but it did not work What am I doing wrong?
[StructLayoutAttribute(LayoutKind.Sequent...
Hi there,
I need to read a textfile and store the data into a Safearray.
I tried it with this function:
bool Parse::LoadTxtFileIntoSafearray(string* strPath, SAFEARRAY** pByteArray)
{
bool bReturn = false;
string line;
int iOffset = 0;
char* pcBuffer = NULL;
std::ifstream infile ( strPath->data() );
if ( !infile.fail() )
{
infil...
I also used VT_RECORD.
But didn't got success in passing safearray of UDTs.
[ComVisible(true)]
[StructLayout(LayoutKind.Sequential)]
public class MY_CLASS
{
[MarshalAs(UnmanagedType.U4)]
public Int32 width;
[MarshalAs(UnmanagedType.U4)]
public Int32 height;
...
Hi, I have an ATL COM object that I am using from C#. The interface currently looks like:
interface ICHASCom : IDispatch{
[id(1), helpstring("method Start")] HRESULT Start([in] BSTR name, [out,retval] VARIANT_BOOL* result);
...
[id(4), helpstring("method GetCount")] HRESULT GetCount([out,retval] LONG* numPorts);
...
[id(7)...
Hello. I have an .NET (4.0) interface which is implemented with a ServicedComponent COM+ class:
interface DotNetIface
{
void MethodRef(var System.Guid guid);
void MethodArray(System.Guid[] guids, params object[] parameters);
void MethodCStyle([MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.Struct, SizeConst=5)]S...
I have a COM object that takes a 0 bounded safearray of two dimensions. I need to pass this array into my C++ COM object. I can pass the VB6 multidim arrays into the C++ side without a problem, but I have no idea how to set this up in C# so that it will be marshalled correctly. Does anyone know the steps to set up a mulitidimensional arr...
Am relatively new to the world of C++. I wish to access the data from a multi-dimensional SAFEARRAY. However when I try to retrieve the value, I get the error 0xC0000005: Access violation reading location 0x40e3e300. Attached below is my code and the marked line is where it errors out. Hopefully someone can shed some light as to how to a...
I am trying to pass an array of ints from C# to C++/CLI. Here's my code:
// SafeArrayTesting_PlusPlus.cpp
#include "stdafx.h"
#include <comdef.h>
using namespace System;
namespace SafeArrayTesting_PlusPlus
{
public ref class MyCppClass
{
public:
MyCppClass();
~MyCppClass();
...
I am trying to pass an array of interfaces from C# to C++/CLI. Here is the code:
// *** SafeArrayTesting_PlusPlus.cpp ***
#include "stdafx.h"
#include <comdef.h>
using namespace System;
using namespace System::Runtime::InteropServices;
namespace SafeArrayTesting_PlusPlus {
public ref class MyCppClass
{
public:
M...
Hi guys,
i am having trouble importing c++ unmanaged dll into C# [winform]. Can someone help?
Basically i am just trying to create a safearray of strings in c++ and trying to send it to C#.
Here is my c++ code.
extern "C" __declspec(dllexport) BOOL GetStringArr(SAFEARRAY* arr)
{
SAFEARRAY* myArray;
SAFEARRAYBOUND rgsabound[1];
...
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 any sample code to do this.
Any help is appreciated
...
can safearrays be passed across process boundaries through com objects ?
...