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

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.
    – JAB
    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.

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.