> Hi,
>
> I have a dll that I'd like to write a simple replacement for in python.
> Is this possible? Is there an example somewhere of a dll written in python?
>
> The example could be for something as simple as a single dll export
> implementing the following GetApiVersion call...
>
> typedef enum _Status
> {
> STATUS_SUCCESS = 0x00000000,
> STATUS_FAILED = 0x00000001
> }Status;
>
> typedef struct _ApiVersionInfo
> {
> DWORD dwMajor;
> DWORD dwMinor;
> DWORD dwDetailed
> }ApiVersionInfo;
>
> Status GetApiVersion(ApiVersionInfo *pstVersion);
>
> My googling turned up this old post from 5 years ago, but nothing more
> recent.
> http://mail.python.org/pipermail/python-list/2001-November/074600.html
>
> Thank you very much for any feedback.
Hi,
I'v made a c-module to simplify embedding/extending Python without the need
of a MS-C compiler (MingW is good enough) and without the hassle of
packing/unpacking/ref-counting/thread-state when communicating with python.
Using my c-module, your dll should look something like:
-------------------------------------------------------
#include "PyLib.h"
typedef enum _Status
{
STATUS_SUCCESS = 0x00000000,
STATUS_FAILED = 0x00000001
}Status;
typedef struct _ApiVersionInfo
{
DWORD dwMajor;
DWORD dwMinor;
DWORD dwDetailed
}ApiVersionInfo;
static initialized = 0;
static Initialize()
{
if (!initialized) {
PyLib_Initialize(NULL, 0, NULL);
PyLib_Import("MyDll", r"C:\Dir\Containing\MyDll");
initialized = 1;
}
}
Status GetApiVersion(ApiVersionInfo *pstVersion)
{
Initialize();
if (PyLib_Call("MyDll.GetApiVersion", "iii()",
&(pstVersion->dwMajor),
&(pstVersion->dwMinor), &(pstVersion->dwDetailed)))
return STATUS_SUCCESS;
else
return STATUS_FAILED;
}
-------------------------------------------------------
and you must create a file "MyDll.py" with something like:
-------------------------------------------------------
def GetApiVersion():
return 1, 1, 0
-------------------------------------------------------
Since the documentation is not ready I've not yet released this to the
general python community.
If you are interested I can send you the code.
>
> Best Regards,
>
> Darren
>
____________________________________________________________________________
Fred Gansevles <mailto:[EMAIL PROTECTED]> Phone: +31 53 489 4613
Org.: Twente University, Fac. of EWI, Box 217, 7500 AE Enschede, Netherlands
"Linux is like a wigwam, No windows, no gates and an apache inside"
_______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32