Questions tagged [safearray]
145 questions
5
votes
2 answers
Can I create a VarArray OleVariant from a buffer (pByte) and size without copying?
I can copy the memory from the buffer into the safe array as follows
function GetVarArrayFromBuffer(ABuffer : pByte; ASizeInBytes: Cardinal) : OleVariant;
var
LVarArrayPtr: Pointer;
begin
Result := VarArrayCreate([0, ASizeInBytes…

Jasper Schellingerhout
- 1,070
- 1
- 6
- 24
5
votes
1 answer
need to call managed code from unmanaged c++ code
I wrote COM class in C#, and one function like this :
public void SignAttached(
byte[] message,
ref byte[] signedMessage,
string userName = "USER"
)
}
when i try to call this function from C++ code i have exeption:…
user3090139
5
votes
2 answers
C# function doesn't update SAFEARRAY
I have a C# function with following signature:
int Get1251Bytes(string source, byte[] result, Int32 lengthOfResult)
I call it from C++. I was informed by compiler that 2-nd param must have SAFEARRAY* type. So I call it in this way:
SAFEARRAY*…

Zharro
- 819
- 1
- 11
- 23
4
votes
3 answers
Sending and receiving arrays over COM
What is the right way to receive and send arrays over COM? Here's my attempt so far: a safearray of doubles wrapped in a variant.
//takes variant holding safearray of doubles
//returns a similar variant having multipled every element by…

Sideshow Bob
- 4,566
- 5
- 42
- 79
4
votes
2 answers
How to create a SAFEARRAY in Windows JScript?
I want to create a SAFEARRAY of type byte in Windows JScript.
Can you give me some example code or point me in the right direction?

shane87
- 3,090
- 12
- 51
- 65
4
votes
1 answer
How to create a SafeArray C#?
I need to create a SafeArray to pass to a COM method.
How do I create/maintain/destroy a SafeArray in C#?
I have never came across SafeArrays before and could not find much with a quick google search, so any help is much appreciated.
EDIT: Added…

shane87
- 3,090
- 12
- 51
- 65
4
votes
3 answers
What is the correct syntax when passing CComSafeArray to a method expecting SAFEARRAY**
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))
{
…

aNDo
- 41
- 1
- 3
4
votes
2 answers
Get an element from SAFEARRAY (or convert it into a long array)
I'm trying to get the elements from a SAFEARRAY (returned as output of a function) in Visual C++.
I've never ever used a SAFEARRAY before, so I don't know how to deal with it. Should I convert the SAFEARRAY into a long array (how?) or can I simply…

merch
- 945
- 8
- 19
4
votes
2 answers
Error on call COM with PSafeArray in delphi7
I have a procedure that I need to call using COM, which is declared like this in C#:
public string ali(int[] num)
{
string r;
r ="";
foreach (int a in num)
{
r = r + Convert.ToString(a) + ";";
}
return r;
}
The…

Aliasghar Yousefian
- 83
- 7
3
votes
1 answer
ATL C++ memory leak with safearray of ccomobjects
I find myself in need of help. Now, I'm not all that unfamiliar with C++, but combining it with ATL provides a whole new level of confusion. Anyways, my problem: I (finally) managed to return an array of objects in my COM method to C# caller. But…

Stonehead
- 366
- 2
- 12
3
votes
0 answers
How does For...Each work under the hood for arrays?
A For...Each loop in VBx uses the IEnumVARIANT member of an object which supports automation with a method of DISPID_NEWENUM = -4 to iterate over its contents.
However the VBx SAFEARRAY is not an automation object deriving from IDispatch (it is not…

Greedo
- 4,967
- 2
- 30
- 78
3
votes
2 answers
How can I marshall between XLOPER and VARIANT?
I'm working on an Excel plugin (XLL), which communicates with COM objects. So, I have to marshall between XLOPER and VARIANT. I've got most of this working, but arrays are definitely a pain. I need to support 1- and 2D arrays.
I imagine someone…

Tim
- 8,912
- 3
- 39
- 57
3
votes
1 answer
Marshaling a SAFEARRAY of VARIANTs that are BYTEs to C#
I create a SAFEARRAY storing VARIANTs that are BYTEs in C++.
When this structure is marshaled to C#, a weird thing happens.
If I print the content of this structure in C# to a WinForms ListBox, e.g.:
byte data[]
TestSafeArray(out…

Mr.C64
- 41,637
- 14
- 86
- 162
3
votes
2 answers
Getting value from two dimensional Safearray in C++
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…

jw33
- 253
- 2
- 6
3
votes
1 answer
How to convert string array to SAFEARRAY or VARIANT or COleVariant?
i'm working about OLE(COM) ,so that i want to convert string array to SAFEARRAY or CComSafeArray or COleSafeArray or VARIANT or COleVariant.
CString[100] -> SAFEARRAY
CString[100] -> CComSafeArray
CString[100] -> COleSafeArray
CString[100] ->…

duyeoung.ryu
- 33
- 4