The business partner created a DLL written in C ++.
Our partner describes that C ++ DLL methods can be accessed using this code in C ++ (we tested it and it works great with this code written in C ++)
create_func_ptr createInstance = (create_func_ptr)(GetProcAddress(hdl, "createReader"));
LudvigInterface* ludvigInterface = createInstance();
if (ludvigInterface)
{
bool isRunning = ludvigInterface->isRunning();
destroy_func_ptr closeInstance = (destroy_func_ptr)(GetProcAddress(hdl, "closeReader"));
closeInstance(ludvigInterface);
}
But our task is that we want to do the same in C #.
We can open the DLL through DLLImport instructions, and everything works well until we try to access the isRunning method.
class Program
{
[DllImport(@"\Libraries\LudvigImplementation.dll")]
private static extern IntPtr createReader();
[DllImport(@"\Libraries\LudvigImplementation.dll")]
private static extern bool isRunning();
static void Main(string[] args)
{
IntPtr LudvigInterfacePtr = createReader();
var a = isRunning();
}
}
How can we solve this? How can we access the isRunning DLL method in C #?
Thank you so much
UPDATED 2. CAN AT 13:31 CET:
I have questions about what LudvigInterface looks like. Here it is (LudvigInterface.h)
class LudvigInterface
{
public:
virtual bool isRunning() = 0;
virtual char* getVersion() = 0;
};
Thanks again
source
share