Re: [ctypes-users] Special use case for ctypes
Brought to you by:
theller
From: Nicolas P. <nic...@aa...> - 2017-05-09 08:16:24
|
One way to do what you want is to create a process linked with your library. This process is the single access point to your C library. This process communicates with other processes (Pyhton and C#) through sockets, pipes or anything else. Le 04/05/2017 à 23:37, Zak Smolen a écrit : > Hi, > > I am trying to do something odd, and I was hoping someone may have > some ideas/guidance. > > My application has a C later, accessed by C# layers. I also have a > python wrapper for that C layer written using ctypes. I would like to > have the C# call python scripts which would then, using my library, do > things to the /same instance /of the C DLL as the C# is using. > > I know this is a complex task, but I feel like it should be possible. > After searching around the source code a bit I found a few things. On > my windows machine (windows-only is fine initially) it is using the > LoadLibrary function from kernel32. Also, the CDLL class is able to > take a handle pointer to use instead of calling LoadLibrary. > > So, I wrote this little wrapper function and I was able to pass in the > handle that the C# is using for the DLL so that the python is using > the same handle. That didn't seem to cut it. Anyone have any ideas > that may help with this task? > > Also, before you suggest it, I know about things like IronPython and > Python for .NET. The issues there are twofold: first, they are > restricted and don't have all libs, especially IronPython. Second, if > I want to use the python library, it still gets a different instance. > > Thanks, > Zak > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > _______________________________________________ > ctypes-users mailing list > cty...@li... > https://lists.sourceforge.net/lists/listinfo/ctypes-users -- *Nicolas PINAULT R&D electronics engineer *** ni...@aa... <mailto:ni...@aa...> *AATON-Digital* 38000 Grenoble - France Tel +33 4 7642 9550 http://www.aaton.com http://www.transvideo.eu French Technologies for Film and Digital Cinematography Follow us on Twitter @Aaton_Digital @Transvideo_HD Like us on Facebook https://www.facebook.com/AatonDigital |