Rectangle 27 7

If the DLL grabs the stdout handles when it is loaded, then you will need to dynamically load the DLL after you have changed the stdout handles in your code.

Definitely a good point, although even now that I load the DLL dynamically (after calling SetStdHandle), I still get no output.

dthorpe, your recommendation worked (I just was not seeing it). Thank you very much.

c++ - Delphi - Capture stdout and stderr output from statically linked...

c++ delphi dll stdout stderr
Rectangle 27 11

Declare a function pointer in Delphi by declaring a function type. For example, the function type for your callback could be defined like this:

type
  TGetProperty = function(object_type, object_instnace, property_identifier, device_identifier: UInt; value: PSingle): Boolean; cdecl;

Note the calling convention is cdecl because your C++ code specified no calling convention, and cdecl is the usual default calling convention for C++ compilers.

Then you can use that type to define the DLL function:

function RegisterCallbackGetProperty(GetProperty: TGetProperty): Boolean; cdecl; external 'dllname';

Replace 'dllname' with the name of your DLL.

To call the DLL function, you should first have a Delphi function with a signature that matches the callback type. For example:

function Callback(object_type, object_instnace, property_identifier, device_identifier: UInt; value: PSingle): Boolean cdecl;
begin
  Result := False;
end;

Then you can call the DLL function and pass the callback just as you would any other variable:

RegisterCallbackGetProperty(Callback);

Calling a callback function in Delphi from a C++ DLL - Stack Overflow

c++ delphi dll delphi-7
Rectangle 27 8

  • It's memory is managed in ole32.dll, so no dependency on either Delphi's memory manager or the CLR GC.
  • You do not have to directly deal with pointers
type
  Sample = static class
  private
    [UnmanagedExport]
    method StringTest([MarshalAs(UnmanagedType.BStr)]input : String;
                      [MarshalAs(UnmanagedType.BStr)]out output : String);
  end;

implementation

method Sample.StringTest(input : String; out output : String);
begin
  output := input + " ~  ";
end;

"MarshalAs" tells the CLR how to marshal strings back and forth. Without it, strings are passed as Ansi (PAnsiChar), which is probably NOT what you would want to do.

procedure StringTest(const input : WideString; out output : WideString);
  stdcall; external 'OxygeneLib';

var
  input, output : WideString;
begin
  input := 'A b c';
  StringTest(input, output);
  Writeln(output);
end.

Also, never ever use types, that are not clearly defined, for external interfaces. You must not use PChar for DLL imports or exports. Because if you do, you will run into exceptions when you compile it with D7 or D2009 (depending on what the original dev system was)

How can I pass a Delphi string to a Prism DLL? - Stack Overflow

delphi delphi-2010 delphi-prism oxygene
Rectangle 27 8

  • It's memory is managed in ole32.dll, so no dependency on either Delphi's memory manager or the CLR GC.
  • You do not have to directly deal with pointers
type
  Sample = static class
  private
    [UnmanagedExport]
    method StringTest([MarshalAs(UnmanagedType.BStr)]input : String;
                      [MarshalAs(UnmanagedType.BStr)]out output : String);
  end;

implementation

method Sample.StringTest(input : String; out output : String);
begin
  output := input + " ~  ";
end;

"MarshalAs" tells the CLR how to marshal strings back and forth. Without it, strings are passed as Ansi (PAnsiChar), which is probably NOT what you would want to do.

procedure StringTest(const input : WideString; out output : WideString);
  stdcall; external 'OxygeneLib';

var
  input, output : WideString;
begin
  input := 'A b c';
  StringTest(input, output);
  Writeln(output);
end.

Also, never ever use types, that are not clearly defined, for external interfaces. You must not use PChar for DLL imports or exports. Because if you do, you will run into exceptions when you compile it with D7 or D2009 (depending on what the original dev system was)

How can I pass a Delphi string to a Prism DLL? - Stack Overflow

delphi delphi-2010 delphi-prism oxygene
Rectangle 27 8

The compiler forbids me to export enums and constants. Am I just not declaring them correctly? I would like calling Delphi s/w to be able to use the enum elements and all callers to be able to use constants.

You cannot export enumerated types and constants. The caller will have to declare them again. The same goes for types.

I should not use any structures because of possible differences in byte alignment between compilers.

Feel free to use records. Alignment is standardised across compilers on the same platform. Do make sure that you use a modern Delphi, XE2 or later, that follows the platform standard for alignment correctly.

So, if I can't accept strctures as parameters. I guess I should just have a long parameter list of integers and PChars?

You can receive records as parameters.

Can I accept arrays as parameters, or does boundary alignment make that dangerous?

You can accept arrays. You need to receive a pointer to the first element, and the number of elements. Array elements are always layed out immediately following the previous elements.

Can I accept/return floats/doubles? Booleans? Or am I stuck with "zero === false and all else is true"?

Yes you can use floating point types and booleans.

I'll mention one more issue, but there surely are more. Don't use records as return types to functions. Delphi does not follow the platform standard in its handling of function return types for records. Use an out parameter instead.

A good way to learn by example what can be done is to study the Windows API.

This is a general question and so here's a general answer. Detailed follow ups would best be handled in specific questions with specific code examples.

"Don't use records as return types to functions. Delphi does not follow the platform standard in its handling of function return types for records." Could you expand on this please? I'm not aware of any problem using returning records, and if there is one I'd like to be :)

@David Delphi passes records as extra implicit var params. The standard platform, as per MS C++ compiler differs. You'll have problems with large records when doing interop with C++, C# etc. Same for WideString. Take a look at my questions sorted by votes to see coverage of WideString return values which is the same issue.

@DavidM Sorry, was on my phone. Yes, it was a question I asked. Here: stackoverflow.com/questions/9349530/

I know no book. All learnt in bits and pieces doing it.

Coding a DLL in Delphi for calling from other languages - Stack Overfl...

delphi dll enums export
Rectangle 27 2

The C++ function receives a function pointer of type

void(*APtrToSendData)(int,int,void *)
procedure ( AUID, AType, ASize: Integer; ABuffer: Pointer ) of object;

This is simply not compatible. The Delphi procedural type has an extra parameter, uses the register calling convention, and is a method of object.

You need to declare TNetMgrSendData as follows:

TNetMgrSendData = procedure(uid, len: Integer; buffer: Pointer); cdecl;

You make life hard for yourself when you declared CreateNetMgr to receive an untyped pointer. It would be much better to declare it like this:

function CreateNetMgr(APtrToSendData: TNetMgrSendData): Pointer; cdecl; 
  external DLL_NAME;

Then you can also refrain from using the @ operator when you call it.

How Can I pass a regular method into the create using this as now it gives the regular procedure and method pointer error?

You cannot. C++ does not know about Delphi methods. If it's C++ Builder then you can use a vendor specific extension in the C++ code that is equivalent to of object. You'd be better off passing an extra void* which contained the Delphi object reference.

__closure

Calling a function in a delphi app from c++ dll - Stack Overflow

c++ delphi dll firemonkey
Rectangle 27 3

When you load a DLL the loader will load all the dependencies for you. These dependencies are listed in the import tables of each DLL and the loader resolves them. You don't need to do anything.

Therefore I can't understand how you came to the conclusion that you yourself needed to process DLL dependencies. Are you loading this DLL in a non-standard way? Do you need a manifest for WinSxS dependencies, i.e. if the MS C runtime is needed? Is there something else we need to know?

All that said, having this DLL loaded into your process is not likely, in my view, to help much in extracting text from a different process which has its own separate virtual memory. In other words, I am quite confident that your current attempt to extract the text will fail. The way to get around the virtual memory barrier is to run your code in the other process using a hook.

+1 Question: Could he use GetWindowText (exact name may differ) if he has the handle for the edit? He must already have the handle for the Window that hosts the edit (previous question). Can you somehow enumerate the handles "parented" by that window? If so and if he has some means of identifying the right one, he should be able to get there with the GetWindowText API?

@marjan this control is not subclassed from EDIT and doesn't return its contents from GetWindowText

@david - First, thanks - you have been very patient and a lot of help with my other posts. I must be missing something here... (this is not my day job!) I tried dynamically loading ter32.dll: dllHandle := LoadLibrary(pwidechar(DllLocation + '\ter32.dll')); and it said that x (I forget which) needed to be loaded first. So... I stumbled blindly along and dynamically loaded x before ter32.dll... and so on. ran into the cyclic dependency. Now... I just tried it again to get you the exact text of the error and it is loading the DLL. Now to try the routines... Thanks!

@marjan - I appreciate the suggestion but... I tried it and as he said, TE Edit does not have the usual edit message handlers.

delphi - Get around 3rd party cyclic dll dependencies? - Stack Overflo...

delphi dll circular-dependency cyclic-reference
Rectangle 27 2

The question is somewhat confused. There is a huge amount of C# code that has no corresponding Delphi code. One wonders if the Delphi code really does exhibit the problem that you claim it does.

Anyway, on the assumption that the GetProcAddress call that you show does fail, then the question is easy enough to answer. GetProcAddress has two failure modes:

  • The module handle supplied is not valid.
  • The procedure name supplied is not valid.

We can rule out item 1 since the module handle was returned by a call to LoadLibrary. If LoadLibrary succeeds then we know that we have a valid module handle.

So, the only conclusion is that the procedure name supplied is not valid. Which means that the DLL that you have loaded does not export a function named MXIO_GetDllVersion. You can confirm this yourself by calling GetLastError immediately after GetProcAddress returns nil. When you do so you will get the value 127 which is ERROR_PROC_NOT_FOUND.

You can confirm this by inspecting the function names that the DLL exports. Use a tool such as Dependency Walker to do so.

One other minor comment on your Delphi code. You've used THandle for the module handle, but that is the wrong type. It won't affect behaviour but it is semantically wrong. Use HMODULE.

David, my Delphi code is just a test code to see if I could read DLL functions, I couldn't start the real prg. I run DependencyWalker and checked out the output, I can see the function name with underscore (I've read in an article that this is normal because of the C++ dll - I tried both possibilities though) in the text output they look like: [C ] 305 (0x0131) 304 (0x0130) _MXIO_GetDllVersion@0 0x000601C0 I think I'm going to give up and may be try to learn c#. Thank you for your help, I appreciated.

_MXIO_GetDllVersion@0 is a stdcall function with a decorated name. Likely exported by the MS C++ compiler, under extern "C", using dllexport. Note that the @0 indicates that the size of the parameters on the stack is 0 and that @0 is part of the function's name. Now that you know the function's name, you can import it with GetProcAddress(..., '_MXIO_GetDllVersion@0'). I think that this question is done now, right?

c# - How to use a DLL and a .cs file in Delphi - Stack Overflow

c# delphi dll
Rectangle 27 7

I wouldn't really call that ideal. It is selfish and short-sighted to make a DLL that requires its consumers to use the same compiler as the DLL used. (Class layout is implementation-defined, and since both modules need to have the same notion of what a class is, they need to use the same compiler.)

Now, that doesn't mean other consumers of the DLL can't fake it. It just won't be as easy for them as the DLL's designer intended.

When you say the callback is implemented through an interface, do you mean a COM-style interface, where the C++ class has nothing but pure virtual methods, including AddRef, Release, and QueryInterface, and they all use the stdcall calling convention? If that's the case, then you can simply write a Delphi class that implements the same interface. There are many examples of that in the Delphi source code and other literature.

If you mean you have a non-COM interface, where the C++ class has only pure virtual methods, but not the three COM functions, then you can write a Delphi class with the same layout. Duplicate the method order, and make sure all the methods are virtual. The Delphi VMT has the same layout as most C++ vtables on Windows implementations, at least as far as the function-pointer order is concerned. (The Delphi VMT has a lot of non-method data as well, but that doesn't interfere with the method addresses.) Just be sure you maintain clear ownership boundaries. The DLL must never attempt to destroy the object; it won't have a C++-callable destructor that the delete operator could invoke.

If you mean that you have an arbitrary C++ class that could include data members, constructors, or non-pure methods, then your task is considerably more difficult. Follow up if this is the case; otherwise, I'd rather not address it right now.

Overall, I'll echo Mason's advice that the DLL should use plain C-style callback functions. A good rule of thumb is that if you stick to techniques you see in the Windows API, you'll be OK. If you're not in control of how to interact with the DLL, then so be it. But if you can make the DLL's external interface more C-like, that would be best. And that doesn't mean you need to abandon the C++-style interface; you could provide two interfaces, where the C-style interface serves as a wrapper for your already-working C++style interface.

I have the C++ interface as an abstract class, barring the COM style interface functions. Good news is that your suggestion worked. I had to implement a pure virtual class in delphi and inherit another class from it. Yeah the VMT and vtables aligned perfectly so my dll could resolve the offset correctly to make the call. +1 for being so liberal explaining all aspects of it.

Callback from a C++ dll to a delphi application - Stack Overflow

c++ delphi dll
Rectangle 27 5

You can't use this function. It's not even safe to use between two Delphi modules unless you use packages. You cannot pass native Delphi classes across a module boundary like that.

You'll need to switch to an interop friendly type. The obvious option is to use an HBITMAP. You will need to modify the Delphi library. If you don't have the source you will need to contact the original developer.

I have the source code but how can I do it? I need a working example.

So write one. The bitmap classes in both c# and delphi provide means to interop with Win32 bitmap handles. Read some documentation and don't be helpless. Make more effort.

image - How to pass a bitmap to a dll written by Delphi in C#? - Stack...

c# image delphi dll bitmap
Rectangle 27 3

I think I would be inclined to wrap the fixed length array in a C# struct.

public struct CString
{
    [UnmanagedType.ByValArray(SizeConst=255)]
    byte[] value;
}

This allows the size to be specified in one place only.

The next hurdle is the return value. The Delphi ABI treats a return value that cannot fit into a register as an additional hidden var parameter. I'll translate that as a C# out parameter.

Finally the two input parameters are declared as const. That means that they are passed by reference.

So the function would be:

[DllImport(dllname, CallingConvention = CallingConvention.StdCall)]
public static extern void Decrypt(
    [In] ref CString S, 
    [In] ref CString Key, 
    out CString Result

I've intentionally avoided any use of text in this because this would appear to be a function that operates on binary data. Many Delphi programmers treat AnsiChar arrays interchangeably with byte arrays in such situations which is often confusing.

I did what you suggested. It seems like I progressed a big. But, I am now getting the error "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Yeah, I messed up the two in out parameters. Try the latest edit.

I tried your method. Now it is able to call the method, but the output is always an array of nulls. Do you think it is the C# code or the Delphi DLL?

How to call this Delphi function from a DLL in C#? - Stack Overflow

c# function delphi dll char
Rectangle 27 3

Delphi's TBitmap class is very different than .NET's Bitmap class. They are not compatible with each other, and neither is safe for interoperability purposes.

You will have to use a raw Win32 HBITMAP handle instead.

function LensFlare(Bitmap: HBITMAP; X, Y: Int32; Brightness: Real): HBITMAP; StdCall;
Begin
  // ...
  Result := Bitmap;
End;
[DllImport("ImageProcessor")]
static extern IntPtr LensFlare(PtrInt bitmap, int x, int y, double Brightness);

[DllImport("gdi32.dll")]
static extern bool DeleteObject(IntPtr hObject);

private void button1_Click(object sender, EventArgs e)
{
    Bitmap b = new Bitmap(@"d:\a.bmp");
    IntPtr hbmp = LensFlare(b.GetHbitmap(), 100, 100, 50);
    try {
        pictureBox1.Image = Image.FromHbitmap(hbmp);
    }
    finally {
        DeleteObject(hbmp);
    }
}

I did the same thing but in C# this error occurs: "A generic error occurred in GDI+.". In Delphi I did "var B: TBitmap; ... B.Handle := Bitmap; B.SaveToFile("D:\A.BMP");" it works but "B.Handle := Bitmap;" causes a problem!.

image - How to pass a bitmap to a dll written by Delphi in C#? - Stack...

c# image delphi dll bitmap
Rectangle 27 1

I've written you some sample code for 2D arrays. It's a bit messy because the marshaller won't naturally handle 2D arrays. Instead I've opted for flattening the arrays, i.e. marshall them as 1D arrays. This won't have great performance characteristics but perhaps that won't be significant for you. Only you can know that.

library mydll;

var
  arr: array of array of Double;

procedure ManagedToNative(RowCount, ColCount: Integer; Values: PDouble); stdcall;
var
  r, c: Integer;
begin
  SetLength(arr, RowCount, ColCount);
  for r := 0 to RowCount-1 do begin
    for c := 0 to ColCount-1 do begin
      arr[r,c] := Values^;
      inc(Values);
    end;
  end;
end;

procedure NativeToManaged(out RowCount, ColCount: Integer; Values: PDouble); stdcall;
var
  r, c: Integer;
begin
  RowCount := Length(arr);
  if RowCount>0 then begin
    ColCount := Length(arr[0]);
  end else begin
    ColCount := 0;
  end;
  if Assigned(Values) then begin
    for r := 0 to RowCount-1 do begin
      for c := 0 to ColCount-1 do begin
        Values^ := arr[r,c];
        inc(Values);
      end;
    end;
  end;
end;

exports
  ManagedToNative,
  NativeToManaged;

begin
end.
using System.Runtime.InteropServices;

namespace ConsoleApplication1
{
    class Program
    {
        [DllImport(@"mydll.dll")]
        private static extern void ManagedToNative(int RowCount, int ColCount, double[] Values);

        [DllImport(@"mydll.dll")]
        private static extern void NativeToManaged(out int RowCount, out int ColCount, double[] Values);

        static double[] Flattened(int RowCount, int ColCount, double[,] arr)
        {
            double[] result = new double[RowCount*ColCount];
            int i = 0;
            for (int r = 0; r < RowCount; r++)
                for (int c = 0; c < ColCount; c++)
                {
                    result[i] = arr[r,c];
                    i++;
                }
            return result;
        }

        static double[,] Expanded(int RowCount, int ColCount, double[] arr)
        {
            double[,] result = new double[RowCount,ColCount];
            int i = 0;
            for (int r = 0; r < RowCount; r++)
                for (int c = 0; c < ColCount; c++)
                {
                    result[r,c] = arr[i];
                    i++;
                }
            return result;
        }

        static void Main(string[] args)
        {
            const int RowCount = 6;
            const int ColCount = 9;

            double[,] arr = new double[RowCount,ColCount];
            for (int r = 0; r < RowCount; r++)
                for (int c = 0; c < ColCount; c++)
                    arr[r,c] = r*c;

            ManagedToNative(RowCount, ColCount, Flattened(RowCount, ColCount, arr));

            int myRowCount, myColCount;
            NativeToManaged(out myRowCount, out myColCount, null);
            double[] flat = new double[myRowCount * myColCount];
            NativeToManaged(out myRowCount, out myColCount, flat);
            double[,] expanded = Expanded(myRowCount, myColCount, flat);

            for (int r = 0; r < RowCount; r++)
                for (int c = 0; c < ColCount; c++)
                    System.Console.WriteLine(arr[r, c] - expanded[r, c]);
        }
    }
}

The code passes a 2D array from C# to Delphi where it is stored. Then the C# code asks for it back. The WriteLine() statements show that the same values are returned as were passed.

I have arranged for NativeToManaged() to return the dimensions of the array even though this code already knows them. In reality your C# code is likely going to want to ask the Delphi code for the array size so that it can allocate memory in which to store the values.

I won't go on and on about why I've done certain things. From previous questions I think you have enough expertise to work it out from this code. If you do have any questions, leave a comment and I'll do my best to shed some light!

@user Are you still interested in this question?

How to send and receive 2D arrays from C# application to Delphi DLL? -...

c# delphi dll pinvoke
Rectangle 27 1

Strings in Delphi Win32 are managed differently from strings in .Net, so you can not pass a .Net string to Delphi Win32 or vice versa.

To exchange strings values you'd better use PChar type which is supported by both compilers. That is the same way you send string values to Windows API functions.

Sorry, this should be an message to the author of the code snippet mentioned above. Clicked wrong Button. But anyway, how does it work to use PChar. Delphi prism does not have a PChar type. if i use pchar in native delphi and string in prism, i get the first char right. But only one char. How to fix this?

Don't worry, Marcus. You don't have enough reputation points yet, so you wouldn't have been able to post a commend at someone else's question anyway. It's a legitimate question. I've edited it for you so it doesn't look like you're trying to send a direct message, which Stack Overflow doesn't support.

PChar is simply a pointer to a character, to send a string like that you need to first point to the first character, and second, specify the length of string data, so that the other end can read data from the start point up to the length of string. If your DLL function is returning any string value, then the other end should provide a memory space, and send its starting address and its length to your function so that your function can write the output data into that memory space.

How do i read from a pointer position to a specified length in prism? I dont know any method to do this. And what datatype do i use in prism. When using Pointer class and want to get the value, its always shown as pointer to void.

How can I pass a Delphi string to a Prism DLL? - Stack Overflow

delphi delphi-2010 delphi-prism oxygene
Rectangle 27 1

Strings in Delphi Win32 are managed differently from strings in .Net, so you can not pass a .Net string to Delphi Win32 or vice versa.

To exchange strings values you'd better use PChar type which is supported by both compilers. That is the same way you send string values to Windows API functions.

Sorry, this should be an message to the author of the code snippet mentioned above. Clicked wrong Button. But anyway, how does it work to use PChar. Delphi prism does not have a PChar type. if i use pchar in native delphi and string in prism, i get the first char right. But only one char. How to fix this?

Don't worry, Marcus. You don't have enough reputation points yet, so you wouldn't have been able to post a commend at someone else's question anyway. It's a legitimate question. I've edited it for you so it doesn't look like you're trying to send a direct message, which Stack Overflow doesn't support.

PChar is simply a pointer to a character, to send a string like that you need to first point to the first character, and second, specify the length of string data, so that the other end can read data from the start point up to the length of string. If your DLL function is returning any string value, then the other end should provide a memory space, and send its starting address and its length to your function so that your function can write the output data into that memory space.

How do i read from a pointer position to a specified length in prism? I dont know any method to do this. And what datatype do i use in prism. When using Pointer class and want to get the value, its always shown as pointer to void.

How can I pass a Delphi string to a Prism DLL? - Stack Overflow

delphi delphi-2010 delphi-prism oxygene
Rectangle 27 4

Why don't you use the .NET Process Class .. it does not make a lot of sense to use interop in this case since you are already using Delphi Prism..

+1; the whole point about .NET is not about learning a language to program it, but to learn what is in the .NET Framework and make use of that. The .NET Framework is huge: en.wikipedia.org/wiki/.NET_Framework

dll - How to call function CreateProcess in Delphi Prism? - Stack Over...

delphi dll createprocess delphi-prism oxygene
Rectangle 27 6

Try initializing the WideStrings (s1,s2,s3,s4, and maybe even o). If I recall correctly, they are dynamic in Delphi and nil (000000000) before you set them up.

You rock MarkusQ! Thanks a lot. I would have given you 100 votes if I could. :)

Nice job! That was what I spotted when I looked at it, too. @Hermant: For future use, remember that local vars (declared in a method body) are for the most part (strings excepted) not initialized and can contain anything. Vars declared globally or as member fields of a class are set to defaults.

.net - Using a COM DLL in delphi - Access violation in MSVCR80D.dll er...

.net delphi com dll delphi-2006
Rectangle 27 3

@Ilya, you are using a wrong syntax for call an external function. You need to use the DllImport keyword to get Windows interop working.

[DllImport("kernel32.dll")]
class function CreateProcess(
            lpApplicationName:String;
            lpCommandLine:String;
            lpProcessAttributes:IntPtr;
            lpThreadAttributes:IntPtr;
            bInheritHandles:Boolean;
            dwCreationFlags:Int32;
            lpEnvironment:IntPtr;
            lpCurrentDirectory:IntPtr;
            lpStartupInfo:STARTUPINFO;
            lpProcessInformation:ProcessInfo):Boolean; external;
namespace ConsoleApplication20;

interface
uses
    System.Diagnostics,
    System.Runtime.InteropServices;


type
PROCESS_INFORMATION =record
    hProcess    : IntPtr;
    hThread     : IntPtr;
    dwProcessId : UInt32;
    dwThreadId  : UInt32;
end;



STARTUPINFO =record
     cb       : UInt32;
    lpReserved: String;
    lpDesktop : String;
    lpTitle   : String;
    dwX       : UInt32;
    dwY       : UInt32;
    dwXSize   : UInt32;
    dYSize    : UInt32;
    dwXCountChars   : UInt32;
    dwYCountChars   : UInt32;
    dwFillAttribute : UInt32;
    dwFlags         : UInt32;
    wShowWindow : ShortInt;
    cbReserved2 : ShortInt;
    lpReserved2 : IntPtr;
    hStdInput   : IntPtr;
    hStdOutput  : IntPtr;
    hStdError   : IntPtr;
end;

  ConsoleApp = class
  private
    [DllImport("kernel32.dll")]
    class method CreateProcess( lpApplicationName: string;  lpCommandLine:string;  lpProcessAttributes:IntPtr; lpThreadAttributes:IntPtr;
                        bInheritHandles:Boolean;dwCreationFlags: UInt32;  lpEnvironment:IntPtr;
                        lpCurrentDirectory:string;var lpStartupInfo:STARTUPINFO;out lpProcessInformation:PROCESS_INFORMATION) : boolean; external;
  public
    class method Main;
  end;

implementation

class method ConsoleApp.Main;
var
lpStartupInfo        : STARTUPINFO;
lpProcessInformation : PROCESS_INFORMATION;
begin
        lpStartupInfo := new STARTUPINFO();
        lpProcessInformation := new PROCESS_INFORMATION();
        Console.WriteLine('Creating Process');
        CreateProcess('C:\WINDOWS\SYSTEM32\notepad.exe', nil, IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, nil, var lpStartupInfo, out lpProcessInformation);
        Console.ReadLine();
end;

end.

dll - How to call function CreateProcess in Delphi Prism? - Stack Over...

delphi dll createprocess delphi-prism oxygene
Rectangle 27 9

If Delphi can understand COM, then you can make a COM wrapper around the .NET DLL.

I am doing this now for an older IDE which doesn't understand .NET, but it understands COM so I am able to use the latest .NET features in my older applications.

Yes, forgot about that route.

This is probably the best way, and Delphi can understand COM. It's got COM interface support built in as a language feature.

c# - I have a c sharp dll. How can I make it usable in other languages...

c# php delphi dll assemblies
Rectangle 27 9

If Delphi can understand COM, then you can make a COM wrapper around the .NET DLL.

I am doing this now for an older IDE which doesn't understand .NET, but it understands COM so I am able to use the latest .NET features in my older applications.

Yes, forgot about that route.

This is probably the best way, and Delphi can understand COM. It's got COM interface support built in as a language feature.

c# - I have a c sharp dll. How can I make it usable in other languages...

c# php delphi dll assemblies