I did not notice any problem so far. For example, to send a string from the script to delphi dll to vb net dll I use this
~delphi dll~ (Plugin.dll)
procedure ShowUN(out UN: WideString); stdcall;
var
GetNid : WideString;
begin
Com2 := CreateOleObject('com.GUI');
GetNid := Com2.ShowNid; // retrieves from vb dll the index of the bot whose username we want
UN := PluginProc(1, GetNid, '', ''); // gets username from the script
if Length(UN) = 0 then
begin
UN := 'Error';
end;
end;
exports
ShowUN;
end.
~vb dll~
<DllImport("Plugin.dll", CallingConvention:=CallingConvention.StdCall)>
Public Shared Sub ShowUN(<MarshalAs(UnmanagedType.BStr)> ByRef UN As String)
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
Dim Uname As String = Nothing : ShowUN(Uname)
If CheckBox1.Checked = True Then
Try
TabPage3.Text = Uname
Catch ex As Exception
MessageBox.Show(String.Format("Error: {0}", ex.Message))
End Try
End If
End Sub
//...
//'com class
Public Function ShowNid() Implements IGUI.ShowNid
Return Class2.Nid //'bot index as string "0"
End Function
~script~
uses
SysUtils, Classes;
function PluginProc(Code: Cardinal; p1, p2, p3: WideString): WideString; stdcall;
begin
case Code of
1: Result := GetControlByIndex(StrToInt(p1)).GetUser.Name;
// ...
end;
end;
procedure StartPlugins;
begin
Script.StartPlugin(Script.Path + '\Plugin.dll', @PluginProc, True);
end;
begin
Script.MainProc(@StartPlugins);
Delay(-1);
end.
This will successfully get the username across. This is done by checking a checkbox in vb dll which triggers the procedure ShowUN in delphi dll which triggers the PluginProc function of the script that retrieves the username.
The thing is that I cannot do this from the script. For example, let's say that the character dies in game. At that point, I want to show the string "Dead" in the GUI (vb dll). So I want the script to initiate this process by calling a procedure similar to ShowUN (without PluginProc) which will in turn send the string to the vb dll. Function PluginProc allows the delphi dll to interact with the script, but not the other way around.
In short, the problem is not related to interoperability with VB/C/C++, but with delphi dll and delphi script. Both are using the same compiler I assume or some kind of sharemem. It is possible that the main program which is closed source exposes the script and the dll in a sharemem space, but I have no knowledge of that. The developer told me to pass the address of a pointer of a procedure/function of the delphi dll from that dll to the script (using PluginProc) and then when needed call the procedure/function from the script using that pointer. But.. I don't know how to make it work.