I got some mixed progress going by your advice:
In my VB code:
Public Class MyProject
' Declare the P/Invoke signature for the DoubleValue function
<DllImport("RungeKutta.dll", CallingConvention:=CallingConvention.Cdecl)>
Private Shared Function RK_Animate(ByVal value As Double)
End Function
<DllImport("RungeKutta.dll", CallingConvention:=CallingConvention.Cdecl)>
Private Shared Function RK_Init() As Integer
End Function
Above I asked ChatGBT to help me with this topic of using p/invoke.
VB:
Private Sub MyProject_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
RK_Init()
RK_Animate(1)
On the C++ Side I have
in my RungeKutta.H
RUNGEKUTTA_API void RK_Animate(double TimeInterval);
extern RUNGEKUTTA_API void RK_Animate(double);
RUNGEKUTTA_API int RK_Init(void);
extern RUNGEKUTTA_API int RK_Init();
RungeKutta.CPP
// An exported function.
RUNGEKUTTA_API void RK_Animate(double TimeInterval)
{
/*
printf("RK_Animate version VS2010Express version TimeInterval = %f",TimeInterval);
if(RK_Universe->Size>0)
{
RK_Universe->Animate(TimeInterval);
}
else
{
printf("\nRK_Animate: Size = 0");
}
*/
}
RUNGEKUTTA_API int RK_Init()
{
static bool alreadycalled = false;
if (alreadycalled == false)
{
printf("\n==================== Hello THIS IS THE INIT FOR RK");
RK_Universe = new ObjectList;
RK_Universe->AddSystem();
printf("\nRK_Universe->Size = %d", RK_Universe->Size);
printf("\nRK_Universe->SizeGravitational = %d", RK_Universe->SizeGravitational);
printf("\nRK_Universe->SizeNonGravitational = %d", RK_Universe->SizeNonGravitational);
printf("\n==================== Hello THIS IS THE END OF INIT FOR RK");
alreadycalled = true;
return 11;
}
else
{
printf("\n==================== Hello THIS IS THE INIT FOR RK BUT ITS ALREADY CALLED SO NOTHING HAPPENED THIS TIME ROUND");
return 101;
}
}
For debugging purposes I have coment out code in the first function but I am still getting the following errors:
VB SIDE:
For RK_Init()
System.EntryPointNotFoundException
HResult=0x80131523
Message=Unable to find an entry point named 'RK_Init' in DLL 'RungeKutta.dll'.
Source=Part2
StackTrace:
at Part2.MyProject.RK_Init()
at Part2.MyProject.MyProject_Load(Object sender, EventArgs e) in C:\Users\david\OneDrive\WORKSPACE\VB\VB2019\REVAMP 6\MyProject.vb:line 280
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
For RK_Animate(1)
System.Runtime.InteropServices.MarshalDirectiveException
HResult=0x80131535
Message=PInvoke restriction: cannot return variants.
Source=Part2
StackTrace:
at Part2.MyProject.RK_Animate(Double value)
at Part2.MyProject.MyProject_Load(Object sender, EventArgs e) in C:\Users\david\OneDrive\WORKSPACE\VB\VB2019\REVAMP 6\MyProject.vb:line 281
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I don't know what to make of it. ChatBotGBT is no help here because it says to check the arguments which in this case are either void or integer.
HIGH REZ IMAGES:
https://drive.google.com/file/d/1ea7K-USS_Y4IkddRabALtp1FjMK9fvEp/view?usp=sharing
https://drive.google.com/file/d/1Ca5NBzuHHX4T_e6uRZus1kB55jU9f1Zf/view?usp=sharing
https://drive.google.com/file/d/159CQ4iQ-qHKdU7fv8F_UbG02BgX_-tBE/view?usp=sharing
https://drive.google.com/file/d/1vBkpyfD9TKcUHvFTt95mKQnSVvPch3yT/view?usp=sharing
https://drive.google.com/file/d/1lwpTE3Q9PcJeksnVj2CpoI7X5RDwNaRU/view?usp=sharing
On a side note Im hiring experts to help me with problems like this as a freelance consultant. Do let me know if you want paid work.