safearray

SAFEARRAY on linux

一曲冷凌霜 提交于 2021-01-21 05:00:08
问题 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. as *unsigned char ) and it's length (eg. as int or size_t ) and write the data somewhere. Something like: HRESULT MyWrite(SAFEARRAY *Data) { unsigned char *data = SafeArrayGetData(Data); size_t length = SafeArrayGetLength(Data); write_data

I tried to add a new template helper function to my class and now I get a LNK2001 error. How to fix?

不羁岁月 提交于 2021-01-07 02:52:47
问题 I asked a couple of questions recently on StackOverflow to see if I could consolidate some functions into one by making use of templates. Those questions were: Can these methods that convert safe arrays into std::list objects be turned into a template function? Can this template function be adapted to account for the following method? I had one more function to try and update so I thought I would give it a go myself. This was the function to update: void CMSATools::ConvertSAFEARRAY_DATE

I tried to add a new template helper function to my class and now I get a LNK2001 error. How to fix?

旧街凉风 提交于 2021-01-07 02:52:36
问题 I asked a couple of questions recently on StackOverflow to see if I could consolidate some functions into one by making use of templates. Those questions were: Can these methods that convert safe arrays into std::list objects be turned into a template function? Can this template function be adapted to account for the following method? I had one more function to try and update so I thought I would give it a go myself. This was the function to update: void CMSATools::ConvertSAFEARRAY_DATE

trouble using unmanaged c++ from c# using dllimport

故事扮演 提交于 2020-01-25 21:40:41
问题 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]; rgsabound[0].lLbound = 0; rgsabound[0].cElements = 5; myArray = SafeArrayCreate(VT_BSTR, 1, rgsabound); VARIANT* pvData = (VARIANT*)(myArray->pvData); pvData[0].vt = VT_BSTR;

When to use SafeArrayAccessData to lock a SAFEARRAY

旧街凉风 提交于 2020-01-24 18:58:39
问题 I'm having a question about when it is necessary to use SafeArrayAccessData to lock a SAFEARRAY, which is passed by managed code. Here is our code. The VARIANT is passed by managed code, with a string array. During code review, somebody suggest to use SafeArrayAccessData/SafeArrayUnAccessData. But he is not sure about why and what's the benefit. Can you share some of your experiences? Thanks! STDMETHODIMP Base::Method1(VARIANT values, VARIANT_BOOL result) { CComSafeArray<BSTR> ids; ids.Attach

Is it possible to marshal ref parameters in SAFEARRAY

旧时模样 提交于 2020-01-03 07:44:33
问题 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(..., {0})", output); } My C++ client is setting up and calling this method. This works fine, but the status and output variables don't appear to be chaining. It's as though they're being passed by value instead of by reference. Here's my client code: InitCLR(); LONG index = 0

Passing an array of interfaces from C# to C++/CLI

只谈情不闲聊 提交于 2019-12-25 02:46:19
问题 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: MyCppClass(); ~MyCppClass(); void SetMyInterfaces( array<SafeArrayTesting_Sharp::MyInterface^>^ myInterfaces); }; MyCppClass::MyCppClass(){} MyCppClass::~MyCppClass(){} void MyCppClass:

On Windows, with a C# authored COM server, can one return a SAFEARRAY both for early bound and late bound code?

被刻印的时光 ゝ 提交于 2019-12-24 01:07:40
问题 The question is quite long, so I'll format with bullet points for easier discussion Introduction I'm writing a C# COM Server. the COM server is for use in Excel VBA both in early binding and late binding modes. My stumbling block is how to return a SAFEARRAY of instantiated classes that works both in early and late binding mode; I get errors. I have done plenty of work on this (all day): I have done some diagnostics and setup the debugger to shed light on the errors I get. I have done some

How to build a SAFEARRAY of pointers to VARIANTs?

你。 提交于 2019-12-21 02:38:11
问题 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? 回答1: Adding to the answers above for reference by future readers: In IDL, SAFEARRAY(...) means a pointer to an array descriptor. But in C++, SAFEARRAY means an array descriptor. So IDL's SAFEARRAY(...) is really C++'s SAFEARRAY * . This confused me to no end. To make things even more

How to iterate through SAFEARRAY **

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 05:33:10
问题 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 strangest thing is that the IDL method signature comes out to be HRESULT __stdcall GetTestStructArray([out] SAFEARRAY ** test_struct_array); instead of HRESULT __stdcall GetTestStructArray([out] SAFEARRAY(TestStruct)* test_struct_array); Any ideas?