I spent more time with this - from c++ when I want to work with the class instance the void pointer refers to I do something like this:
class AppLicense {
public:
AppLicense() {}
virtual LicenseStatus GetApplicationStatus() = 0;
}
But I couldn't figure out how to do that in Python. This does not work:
class AppLicense(object):
def GetApplicationStatus(self):
pass
So instead I exported another function in the dll like this:
extern "C" {
int P_GetApplicationStatus(void *ptr) {
try {
AppLicenseImpl * ref = reinterpret_cast<AppLicenseImpl *>(ptr);
return ref->GetApplicationStatus();
} catch (...) {
return 0; // License Error default.
}
}
}
Once I had that in place, using it from Python is accomplished like this:
d.GetLicense.restype = ctypes.c_void_p
p = d.GetLicense()
d.C_GetApplicationStatus.argtypes = [ctypes.c_void_p]
status = d.P_GetApplicationStatus(p)