473,382 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

passing C# array by ref to Delphi Com dll

2
Hi,

I have to pass an array by ref to a referenced Delphi Com dll, but all my attempts end in an error.
I'm using VS2003 and I referenced the com dll in my project with 'add reference'.
The Delphi dll has e.g. a procedure Test with a parameter aParam:
Expand|Select|Wrap|Line Numbers
  1.  procedure Test(var aParam: OleVariant) 
After referencing in C# this procedure is:
Expand|Select|Wrap|Line Numbers
  1.  void Test(ref object aParam) 
The aParam parameter is a 1-dimensional array with floats.
I tested with this code:
Expand|Select|Wrap|Line Numbers
  1. object testparam = new float[] {1, 2, 3};
  2. Test(ref testparam);
but the Delphi dll returns an exception with the message 'Variant is not an array'.

What can I do?

Thanks!
Apr 26 '07 #1
2 6793
radcaesar
759 Expert 512MB
Try This,

System.Array=new new float[] {1, 2, 3};
Test(ref testparam);


Hi,

I have to pass an array by ref to a referenced Delphi Com dll, but all my attempts end in an error.
I'm using VS2003 and I referenced the com dll in my project with 'add reference'.
The Delphi dll has e.g. a procedure Test with a parameter aParam:
Expand|Select|Wrap|Line Numbers
  1.  procedure Test(var aParam: OleVariant) 
After referencing in C# this procedure is:
Expand|Select|Wrap|Line Numbers
  1.  void Test(ref object aParam) 
The aParam parameter is a 1-dimensional array with floats.
I tested with this code:
Expand|Select|Wrap|Line Numbers
  1. object testparam = new float[] {1, 2, 3};
  2. Test(ref testparam);
but the Delphi dll returns an exception with the message 'Variant is not an array'.

What can I do?

Thanks!
Apr 26 '07 #2
TeeJee
2
this is not building, testparam has to be type object
Apr 27 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
10
by: Ding Dang | last post by:
I have been using Delphi for a few years, now using Delphi8 and VC#. I just had a preview on VC# 2.0. I was wondering why there is no array property? While there is in VB.net, Delphi.net and IL....
2
by: Claire | last post by:
After giving up on passing nested structs to an unmanaged DLL, I planned that I'd pass a simple buffer of bytes (the same size as the struct) to the dll, convert to a memory stream and read in the...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
5
by: Jozza | last post by:
Hi all, i can't figure out what this means. i'm trying to rewrite it in delphi. Can anyone help? declaration: word pp; word j;
45
by: Skybuck Flying | last post by:
Hello, How to convert this Delphi code for Win32 to C or C++ Win32 code ? var vArray : array of array of array of integer; x,y,z : integer; begin
0
by: Megabeans | last post by:
Hi Im trying to get my vb program to talk to a Delphi written dll. I can get it to work as long as I only ask for the first char in a string but I cant seem to return the whole string from the dll...
6
Sepidar
by: Sepidar | last post by:
When I pass an array argument to a com object, I receive "Index out of Range" exception. I solved this in Delphi by change of start index of array from 0 to 1. But I don't know if this is the same...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.