Python DLL Woes

Rajat Chopra rajat at cs.utexas.edu
Tue May 7 14:14:42 EDT 2002


Hello,

I have a DLL with some functions that allow me to connect to a database
and issue queries and so forth. The DLL itself is written in C++ and I
have written code in C++ (and C) to utilize the functions within the DLL
to connect & manipulate the database.

I have a need to wrap the functions in the DLL using Python. I am
employing the standard methodology (found in the Python DOCS) and
following the templates I have written in C/C++ to wrap each function in
the DLL.  However, when I run my Python module I get an error which is
perplexing.

In C++, I do:

handle = (HINSTANCE) LoadLibrary("SlgxApi.dll");
typedef LPBYTE (CALLBACK* SLAPI_LOGGEDIN) (void);
SLAPI_LOGGEDIN LoggedIn;
LoggedIn = (SLAPI_LOGGEDIN)GetProcAddress(handle, "slapi_LoggedIn");
boolResult = (BOOL) LoggedIn();

This works fine for this and all other functions directly in C++.

My C++ wrapper to be used by Python, is almost identical:

static PyObject *slgx_LoggedIn(PyObject *self, PyObject *args) {

        handle = (HINSTANCE) LoadLibrary("SlgxApi.dll");
        typedef LPBYTE (CALLBACK* SLAPI_LOGGEDIN) (void);
        SLAPI_LOGGEDIN LoggedIn;
        LoggedIn = (SLAPI_LOGGEDIN)GetProcAddress(handle, "slapi_LoggedIn");
        boolResult = (BOOL) LoggedIn();
}

While I didn't show all the C++ Wrapper code, when I export the wrapper
and execute it within Python, I get the following error:

ERROR --> Could not find entry point for slapi_LoggedIn

I don't know why I am getting this error and don't really know what would
be causing it. I'd appreciate any help on your part. (Also, I want to use
the C++ wrapper approach rather than CALLDLL by Sam Rushing because there
are some type-specific issues that are most easily resolvable using the
C++ wrapper).

Thanks,

Rajat



More information about the Python-list mailing list