Python: accessing DLLs from Python (2)

.NET + CLR:

This is short example on how to access object using "boxed" class:

Let say in our somelib.dll .NET library we have:

- class NewClass but without any known callable constructor

- function: int someFunction(out: NewClass)
- above function is supposed to return newly created object NewClass.

import clr
import System
from System.Collections import *
clr.AddReference("somelib")
import somelib
 
return_int = 0
justNewClass = System.Array.CreateInstance(somelib.NewClass, 1)
 
justNewClass[0]
[return_int, justNewClass) = somelib.someFunction(justNewClass[0])

Above should return newly created object as justNewClass and return integer value
as return_int

Refer also to:
- Python: accessing DLLs from Python
- http://pythonnet.sourceforge.net/readme.html