I’m trying to integrate with a windows based api using c-sharp and I’ve run into this issue.
The api sends me a pointer to a struct that holds a bunch of virtual methods
struct CApiInterface
{
virtual int __stdcall Version(void);
...
}
My question is, how can I call methods off this in C#? I’d like to do something like:
CApiInterface _api;
public void Start(CApiInterface* api)
{
_api = api;
}
...
public void SomeOtherMethod()
{
_api.version();
}
I would like to stay out of CLI/C++ if at all possible, if this is even possible to begin with.
Check out this question for an example of someone else who did the same thing. It seems to revolve around using delegates marked with the
UmanagedFunctionPointerAttribute.