I am creating a C# DLL that will be used as a plug-in for the PLSQL Developer IDE, which is designed in C++.
My C# DLL needs to accept a C++ pointer, then assign that pointer to a function or method, to be called later on.
The IDE provides a specifications document for building these plug-in's, but it only provides samples for C++ and Delphi. The specifications document provides more information I included in this screenshot.
Provided C++ Example:
void (*IDE_MenuState)(int ID, int Index, BOOL Enabled);
BOOL (*IDE_Connected)();
void (*IDE_GetConnectionInfo)(char **Username, char **Password, char **Database);
void (*IDE_GetBrowserInfo)(char **ObjectType, char **ObjectOwner, char **ObjectName);
void RegisterCallback(int Index, void *Addr)
{
switch (Index)
{
case 10 :
(void *)IDE_MenuState = Addr;
break;
case 11 :
(void *)IDE_Connected = Addr;
break;
case 12 :
(void *)IDE_GetConnectionInfo = Addr;
break;
case 13 :
(void *)IDE_GetBrowserInfo = Addr;
break;
}
}
C# I Have So Far:
I should note that I am using Robert Gieseckes Unmanaged Exports NuGet Package for exporting functions. I can change this if necessary.
public bool IDE_Connected()
{
return false;
}
public void IDE_MenuState(int ID, int Index, bool Enabled)
{
}
[DllExport("add", CallingConvention = CallingConvention.Cdecl, ExportName= "RegisterCallback")]
public static void RegisterCallback(int Index, IntPtr Addr)
{
if (Index == 10)
{
// Assign IntPtr Addr to IDE_MenuState()
// Please help :)
}
if (Index == 11)
{
// Assign IntPtr Addr to IDE_Connected()
// Please help :)
}
}
How can I assign the C++ pointer argument to my C# methods?