[Python-Dev] Importing extensions on Windows 95 (original) (raw)

M.-A. Lemburg mal@lemburg.com
Tue, 01 May 2001 12:30:57 +0200


Mark Hammond wrote:

> Here's a stab at a patch. Could you review it and test it ? I > don't have enough knowledge of win32 for this... I think we can drop the getcwd call here completely. I prefer the patch below.

If this works as expected, please check in the patch. (Note that I have not tested the patch I posted -- I've never used VC++ for anything else than compiling C extensions and GMP.)

Mark.

Index: dynloadwin.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/dynloadwin.c,v retrieving revision 2.7 diff -u -r2.7 dynloadwin.c --- dynloadwin.c 2000/10/05 10:54:45 2.7 +++ dynloadwin.c 2001/05/01 00:36:40 @@ -163,24 +163,21 @@ #ifdef MSWIN32 { - HINSTANCE hDLL; + HINSTANCE hDLL = NULL; char pathbuf[260]; - if (strchr(pathname, '\') == NULL && - strchr(pathname, '/') == NULL) - { - /* Prefix bare filename with "." */ - char *p = pathbuf; - *p = '\0'; - getcwd(pathbuf, sizeof pathbuf); - if (*p != '\0' && p[1] == ':') - p += 2; - sprintf(p, ".\%-.255s", pathname); - pathname = pathbuf; - } - /* Look for dependent DLLs in directory of pathname first */ - /* XXX This call doesn't exist in Windows CE */ - hDLL = LoadLibraryEx(pathname, NULL, - LOADWITHALTEREDSEARCHPATH); + LPTSTR dummy; + /* We use LoadLibraryEx so Windows looks for dependent DLLs + in directory of pathname first. However, Windows95 + can sometimes not work correctly unless the absolute + path is used. If GetFullPathName() fails, the LoadLibrary + will certainly fail too, so use its error code */ + if (GetFullPathName(pathname, + sizeof(pathbuf), + pathbuf, + &dummy)) + /* XXX This call doesn't exist in Windows CE */ + hDLL = LoadLibraryEx(pathname, NULL, + LOADWITHALTEREDSEARCHPATH); if (hDLL==NULL){ char errBuf[256]; unsigned int errorCode;

-- Marc-Andre Lemburg


Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/