0

I want to use OpcDaNet.dll in python, I use for that ctypes, but to be able to use the functions I'm intersted in, I have to create an instance of OpcServer Object, how can I do that with Ctypes?

thanks for your answres

asked Jul 12, 2011 at 14:51
1
  • What language was the DLL written in? C? C++? C doesn't have object instantiation, and ctypes doesn't play nice with much else if I'm not mistaken. Commented Jul 12, 2011 at 16:24

2 Answers 2

1

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.

answered May 9, 2012 at 0:53
Sign up to request clarification or add additional context in comments.

Comments

1

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.

answered Jan 29, 2015 at 9:15

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.