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 832311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:20:32+00:00 2026-05-15T04:20:32+00:00

How to use in C# function from Win32 DLL file made in Delphi. When

  • 0

How to use in C# function from Win32 DLL file made in Delphi. When function parameters are custom delphi objects?

Function definition in Delphi:

function GetAttrbControls(    Code     : PChar;
                              InputList: TItemList;
                              var Values   : TValArray): Boolean; stdcall; export;

Types that use:

type
  TItem = packed record
    Code : PChar;
    ItemValue: Variant;
  end;

TItemList = array of TItem;

TValArray = array of PChar;

Example in C# (doesn’t work):

[StructLayout(LayoutKind.Sequential)]
 public class Input
 {
     public string Code;
     public object ItemValue;
 };


[DllImport("Filename.dll", EntryPoint = "GetValues", CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
    public static extern bool GetValues(string Code, Input[] InputList, ref StringBuilder[] Values);
  • 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-15T04:20:32+00:00Added an answer on May 15, 2026 at 4:20 am

    This can’t be done your way, bud you have still some possibilities.

    Dynamic array (declared w/o []), string (AnsiString) and Variant are pointers to “magic” structures (they have reference count and other data on negative offsets), which are handled by compiler intrinsic.

    If you really want to use these types, you’ll need to serialize and materialize them around the interface (using some binary dump format, JSON, etc).

    You may try to use any of the basic types (eg. array[], ShortString, record) which will work exactly as you expect (beware of the ShortString 1-based indexing with length stored at 0) using StructLayout, unless you mix them with managed types.

    Also I’ve got some good experience using interfaces (IInterface/IDispatch via COM InterOp) to directly pass object references between Delphi and C# code.
    You are limited to calling the interfaces’ methods, of course, but the interop layer can handle at least WideString (nicely) and some kinds of Variant (ugly) for you.

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

Sidebar

Related Questions

I'm trying to use the StringEscapeUtils.escapeXML() function from org.apache.commons.lang... There are two versions of
I want to use the Publish.GacRemove function to remove an assembly from GAC. However,
Should I use textbox.text.Trim() function every time when I insert any data from web
In VB.NET, which is better to use: function overloading or default parameters?
Is it possible to use PHP's SimpleXML functions to create an XML object from
I currently use this function to wrap executing commands and logging their execution, and
Which algorithm does the JavaScript Array#sort() function use? I understand that it can take
In JavaScript, you can use Lazy Function Definitions to optimize the 2nd - Nth
I often use the execv() function in C++, but if some of the arguments
When you use the POISSON function in Excel (or in OpenOffice Calc), it takes

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.