I got a little problem trying to build a dll that can be used from .net
I has to do with structures / record.
Anybody knows of a right way to use structure and record to pass to a dll (dll lazarus)?
Pointers dont work very well... or I dont get them right.
Passing a pointer to structure using mashal:
(NewFaborderis a structure like this)
Public Structure FabOrder
Public NumOrder As Int32
Public Material As Int32
Public Numero As Int32
End Structure
BufPtr = Marshal.AllocHGlobal(Marshal.SizeOf(NewFaborder))
Marshal.StructureToPtr(NewFaborder, BufPtr, False)
<System.Runtime.InteropServices.DllImport("PRint_partes_dll.dll", charset:=CharSet.Auto, EntryPoint:="ReceiveOrderAndShowNumOrder", CallingConvention:=CallingConvention.StdCall)> _
Private Shared Function ReceiveOrderAndShowNumOrder(ByRef ptr As FabOrder) As FabOrder
End Function
Also tried:
Private Shared Function ReceiveOrderAndShowNumOrder(ByRef ptr As int64) As int64
End Function
and using it at dll function:
Function ReceiveOrderAndShowNumOrder(Stringer:PFaborder):PFaborder;stdcall;
begin
Result:=Stringer;
end;
Being:
PFaborder=^TFabOrder;
and
TFabOrder=record
NumOrder:int32;
Material:int32;
Numero:int32;
end;
SHould return same NEWFABORDER.
but even it does not give any error or exception, data is not correct.
I got Main doubt: What kind of data shoud I use to send Pointer to the dll????
Private Shared Function ReceiveOrderAndShowNumOrder(??????) As ??????
IntPtr is what I see I can get with vb.net but....
thanks