diff options
author | Mark Hammond <mhammond@skippinet.com.au> | 2001-05-09 00:50:59 (GMT) |
---|---|---|
committer | Mark Hammond <mhammond@skippinet.com.au> | 2001-05-09 00:50:59 (GMT) |
commit | fb1f68ed7cc1536482d1debd70a53c5442135fe2 (patch) | |
tree | 3b141fb28542459696ef72614f48a28225480046 /Python/dynload_win.c | |
parent | b4bbcd76ea312f3bb2304671e8b022266175a7ea (diff) | |
download | cpython-fb1f68ed7cc1536482d1debd70a53c5442135fe2.zip cpython-fb1f68ed7cc1536482d1debd70a53c5442135fe2.tar.gz cpython-fb1f68ed7cc1536482d1debd70a53c5442135fe2.tar.bz2 |
Always pass a full path name to LoadLibraryEx(). Fixes some Windows 9x problems. As discussed on python-dev
Diffstat (limited to 'Python/dynload_win.c')
-rw-r--r-- | Python/dynload_win.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/Python/dynload_win.c b/Python/dynload_win.c index d5f712b..a5a65cf 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -163,24 +163,21 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, #ifdef MS_WIN32 { - 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, - LOAD_WITH_ALTERED_SEARCH_PATH); + 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, + LOAD_WITH_ALTERED_SEARCH_PATH); if (hDLL==NULL){ char errBuf[256]; unsigned int errorCode; |