I want to use OpcDaNet.dll in python, I use for that ctypes, but to be able to use the functio开发者_StackOverflowns I'm intersted in, I have to create an instance of OpcServer Object, how can I do that with Ctypes?
thanks for your answres
In order to use C++ concepts like objects and classes with CTypes you need to need to make a C interface to the class you are using. This is demonstrated in the second answer here. If you don't have access to the source for the external library you want to call, you can try writing a quick library yourself where you wrap OpcDaNet.dll. This can be pretty tedious if you need a lot of different functions from the library, but unfortunately CTypes is fundamentally incompatible with C++ due to the way C++ handles name-mangling.
In fact,you can't create an instance of OpcServer Object if you use the moudle ctypes.Because C
is not Object-Oriented language.If you use C++ to make a .dll file,you should make a C interface,in program such as extern "C"
,if you return an object in this .dll file,python' function can't recieve this object.If I'm not mistaken.If you really want to return an object in the dll file,maybe you can use boost.python to develop the dll file.
精彩评论