[IronPython] Calling external API from IronPython

Ryan Dawson rdawson at exchange.microsoft.com
Fri Sep 22 18:10:12 CEST 2006


The question is relevant, but this isn't supported directly from IronPython in 1.0.  The workaround is to write a small wrapper library in VB or C# and call that from IronPython.

The limitation is rooted in the fact that 1.0 doesn't support .NET attributes, like the DllImportAttribute.  Possible future solutions to this have been discussed on the list previously.  We're hopeful a later version will be able to directly meet your needs here.

        -Ryan


-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of David Anton
Sent: Thursday, September 21, 2006 11:44 AM
To: users at lists.ironpython.com
Subject: [IronPython] Calling external API from IronPython


Is there a way to declare external API functions (non-assembly based) called
from Python code?

e.g., in VB, you'd do something like declare the following stub:
Private Declare Function FriendlyName Lib "kernel32" Alias
"ActualAPIFunctionName"(ByVal SomeString As String) As Integer

e.g., in C#, you'd do it this way:
[System.Runtime.InteropServices.DllImport("kernel32",
EntryPoint="ActualAPIFunctionName", ExactSpelling=false,
CharSet=System.Runtime.InteropServices.CharSet.Ansi, SetLastError=true)]
private static extern int FriendlyName(string SomeString);

Or is this irrelevant in Python (and why)?  I'm learning Python and I'm
continually surprised at how many things are just not even relevant in
Python (explicit types, interfaces, abstract methods, namespaces, etc....).

--
View this message in context: http://www.nabble.com/Calling-external-API-from-IronPython-tf2313707.html#a6434143
Sent from the IronPython mailing list archive at Nabble.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