Special use case for ctypes

Zak Smolen <[email protected]> Thu, 4 May 2017 17:37:34 -0400
Newsgroups gmane.comp.python.ctypes
Message-ID <CAODUn54zKuj-+yzghC_noZzTT8VeDSGQzJQt5Yu+STMDMc=X3A@mail.gmail.com>
--===============4224776669774607667==
Content-Type: multipart/alternative; boundary=001a1144d752c0ad65054eb9945e

--001a1144d752c0ad65054eb9945e
Content-Type: text/plain; charset=UTF-8

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

--001a1144d752c0ad65054eb9945e
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<div><br></div><div>I am trying to do something odd, an=
d I was hoping someone may have some ideas/guidance.<br><br>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 scri=
pts which would then, using my library, do things to the <i>same instance <=
/i>of the C DLL as the C# is using.</div><div><br></div><div>I know this is=
 a complex task, but I feel like it should be possible. After searching aro=
und the source code a bit I found a few things. On my windows machine (wind=
ows-only is fine initially) it is using the LoadLibrary function from kerne=
l32. Also, the CDLL class is able to take a handle pointer to use instead o=
f calling LoadLibrary.</div><div><br></div><div>So, I wrote this little wra=
pper 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&#39;t seem =
to cut it. Anyone have any ideas that may help with this task?</div><div><b=
r></div><div>Also, before you suggest it, I know about things like IronPyth=
on and Python for .NET. The issues there are twofold: first, they are restr=
icted and don&#39;t have all libs, especially IronPython. Second, if I want=
 to use the python library, it still gets a different instance.</div><div><=
br></div><div>Thanks,</div><div>Zak</div></div>

--001a1144d752c0ad65054eb9945e--


--===============4224776669774607667==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--===============4224776669774607667==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ctypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ctypes-users

--===============4224776669774607667==--