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

Ask A Question

Stats

  • Questions 495k
  • Answers 495k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Update: answer rewritten. The original asker found the following answer… May 16, 2026 at 11:23 am
  • Editorial Team
    Editorial Team added an answer First lets get a few things straightened out. Delphi.NET is… May 16, 2026 at 11:23 am
  • Editorial Team
    Editorial Team added an answer In ASP.NET 4 the <%: xyz %> syntax will do… May 16, 2026 at 11:23 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have some misunderstanding about the gslice function. Definition from MSDN states: gslice defines
I’m trying to create a simple Win32 DLL. As interface between DLL and EXE
I have been provided with a C++ DLL and associated header file in order
If you want to call a C/C++ function from inline assembly, you can do
I'd like to execute a function from the top of the stack. That is,
I am refactoring a large and complicated code base in .NET that makes heavy
Our product contains a task-manager system that allows applications to run code in a
I'm trying to use this library : http://pastebin.com/xgPXpGtw (an example of use: http://pastebin.com/fNFAW3Fh )
I have a program (NWShader) which hooks into a second program's OpenGL calls (NWN)
This is probably a really easy question to answer, but for some reason I'm

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.