Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 415027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:20:26+00:00 2026-05-12T18:20:26+00:00

I am trying to call a procedure in a Delphi DLL from C#. The

  • 0

I am trying to call a procedure in a Delphi DLL from C#. The procedure expects the caller to preallocate and input an array of array of TSomeRecord, of which it will then manipulate the TSomeRecord elements as a means of returning results. So, I need to hand-craft Delphi dynamic arrays of arrays of X.
Now, I have found here that a dynamic array of X consists of a pointer to the first element of the dynamic array, and that that first element has a reference count and the length (number of elements) of the array prepended (both 32-bit integers), and that the elements are stored inline and contiguously, so that the whole thing looks like this in memory:

rrrrllll000...000111...12...
        ^

with rrrr the reference count, llll the length, 0123 the elements, and ^ where the pointer points to. This bears out; I have tested it and it works.
For multidimensional dynamic arrays I have assumed that I can substitute array of Y for the X in array of X, in other words that the outer dimension is simply a dynamic array of (pointers to) dynamic arrays, like so:

rrrrllll000011112222...
        ^

where the elements 0000, 1111 etc are now 32 bit pointers to independently allocated dynamic arrays. Doing it this way, however, earns me an access violation for my troubles. This is apparently not how Delphi expects me to do it. Can anyone explain to me how I am supposed to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:20:26+00:00Added an answer on May 12, 2026 at 6:20 pm

    A dynamic array is a pointer to a packed block of elements.

    So array of array of TSomeRecord is a pointer to an array of pointers, each of which points to a block memory with length(array[firstlevel]) elements, or nil if there are none.

    In other words, what you assume is roughly correct, with the addition that arrays with zero elements are nil. Note that you are not supposed to change reference count and length yourself unless you REALLY know what you are doing.

    Determining what causes your crash will be hard without example code. Keep in mind that, as for ALL automated Delphi types (except widestring), all dynamic memory must be allocated by the delphi memory manager.

    Attempts to that using the memory manager of whatever language you are interfacing to is not possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display the progress of a POST call from my TIdHTTP
I'm trying to integrate two Fortran 9x codes which contain data arrays with opposite
I am trying to access MySQL stored procedures from a perl script but I
I'm trying to understand different ways of getting table data from Oracle stored procedures
I'm trying to develop some code to make generic calls to methods by it's
I am trying to find if the below is a well documented pattern (or
I am trying to connect the Sql Server 2008 R2 with java using JDBC.I
I have sybase stored procedures that I have written which we use in our
I'm trying to learn ASP.NET MVC 3 with razor and so far getting the
I was tying to optimize a piece of code that has this construct: while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.