[IronPython] Calling a System DLL In IronPython?

Michael Foord fuzzyman at voidspace.org.uk
Sun Jan 24 13:18:39 CET 2010


For ctypes you should use the documentation that is part of the Python  
documentation. For PInvoke the references will be mainly for C#.

Does anyone have examples of using PInvoke with clrtype and IronPython  
2.6?

Michael


--
http://www.ironpythoninaction.com

On 24 Jan 2010, at 03:24, David McWright <david.mcwright at usbfmi.com>  
wrote:

> Is there a reference somewhere for PInvoke or ctypes in IP?
>
> TIA,
> David
>
> On Jan 23, 7:31 pm, Michael Foord <fuzzy... at voidspace.org.uk> wrote:
>> On 24/01/2010 00:19, Andrew Evans wrote:
>>
>>> I am trying to call user32.dll into IronPython how do I do this?  
>>> Do I
>>> use clr.AddReference, that doesn't seem to do it.
>>
>> clr.AddReference only works for .NET assemblies. user32.dll is not a
>> .NET assembly. To use it you will either need PInvoke or ctypes that
>> comes with IronPython 2.6.
>>
>> PInvoke relies on .NET attributes. It used to be the case that you
>> couldn't use these directly with IronPython but needed a simple C#
>> wrapper. The following article shows how to call into user32.dll  
>> using a
>> C# wrapper:
>>
>>      http://www.voidspace.org.uk/ironpython/winforms/part10.shtml
>>
>> Alternatively you can try clrtype.py that comes with IronPython 2.6.
>>
>> All the best,
>>
>> Michael Foord
>>
>>
>>
>>> Suggestions
>>
>>> _______________________________________________
>>> Users mailing list
>>> Us... at lists.ironpython.com
>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
>> --http://www.ironpythoninaction.com/http://www.voidspace.org.uk/blog
>>
>> READ CAREFULLY. By accepting and reading this email you agree, on  
>> behalf of your employer, to release me from all obligations and  
>> waivers arising from any and all NON-NEGOTIATED agreements,  
>> licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap,  
>> confidentiality, non-disclosure, non-compete and acceptable use  
>> policies ("BOGUS AGREEMENTS") that I have entered into with your  
>> employer, its partners, licensors, agents and assigns, in  
>> perpetuity, without prejudice to my ongoing rights and privileges.  
>> You further represent that you have the authority to release me  
>> from any BOGUS AGREEMENTS on behalf of your employer.
>>
>> _______________________________________________
>> Users mailing list
>> Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/ 
>> users-ironpython.com
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list