[Python-checkins] distutils/misc install.c,1.21,1.22 wininst.exe,1.17,1.18
theller@users.sourceforge.net
theller@users.sourceforge.net
Thu, 07 Nov 2002 08:46:23 -0800
Update of /cvsroot/python/distutils/misc
In directory usw-pr-cvs1:/tmp/cvs-serv13413/misc
Modified Files:
install.c wininst.exe
Log Message:
Use dynamic linking for the SHGetSpecialFolderPath function, it is not
always available on Windows NT. When the function cannot be loaded,
get_special_folder_path raises OSError, "function not available".
Compiled the exe, and rebuilt bdist_wininst.py.
Index: install.c
===================================================================
RCS file: /cvsroot/python/distutils/misc/install.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** install.c 5 Nov 2002 10:02:03 -0000 1.21
--- install.c 7 Nov 2002 16:46:20 -0000 1.22
***************
*** 390,403 ****
char lpszPath[MAX_PATH];
int i;
if (!g_PyArg_ParseTuple(args, "s", &name))
return NULL;
for (i = 0; i < DIM(csidl_names); ++i) {
if (0 == strcmpi(csidl_names[i].name, name)) {
int nFolder;
nFolder = csidl_names[i].nFolder;
! if (SHGetSpecialFolderPath(NULL, lpszPath, nFolder, 0))
! return g_Py_BuildValue("s", lpszPath);
else {
g_PyErr_Format(g_PyExc_OSError, "no such folder (%s)", name);
--- 390,423 ----
char lpszPath[MAX_PATH];
int i;
+ static HRESULT (WINAPI *My_SHGetSpecialFolderPath)(HWND hwnd,
+ LPTSTR lpszPath,
+ int nFolder,
+ BOOL fCreate);
+
+ if (!My_SHGetSpecialFolderPath) {
+ HINSTANCE hLib = LoadLibrary("shell32.dll");
+ if (!hLib) {
+ g_PyErr_Format(g_PyExc_OSError, "function not available");
+ return NULL;
+ }
+ My_SHGetSpecialFolderPath = (BOOL (WINAPI *)(HWND, LPTSTR, int, BOOL))
+ GetProcAddress(hLib,
+ "SHGetSpecialFolderPathA");
+ }
if (!g_PyArg_ParseTuple(args, "s", &name))
return NULL;
+ if (!My_SHGetSpecialFolderPath) {
+ g_PyErr_Format(g_PyExc_OSError, "function not available");
+ return NULL;
+ }
+
for (i = 0; i < DIM(csidl_names); ++i) {
if (0 == strcmpi(csidl_names[i].name, name)) {
int nFolder;
nFolder = csidl_names[i].nFolder;
! if (My_SHGetSpecialFolderPath(NULL, lpszPath, nFolder, 0))
! return g_Py_BuildValue("s", lpszPath);
else {
g_PyErr_Format(g_PyExc_OSError, "no such folder (%s)", name);
***************
*** 1675,1679 ****
int result;
result = run_installscript(hPython, fname, 2, argv);
! if (result) {
fprintf(stderr, "*** run_installscript: internal error 0x%X ***\n", result);
}
--- 1695,1699 ----
int result;
result = run_installscript(hPython, fname, 2, argv);
! if (-1 == result) {
fprintf(stderr, "*** run_installscript: internal error 0x%X ***\n", result);
}
Index: wininst.exe
===================================================================
RCS file: /cvsroot/python/distutils/misc/wininst.exe,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
Binary files /tmp/cvsbJ0yLZ and /tmp/cvsihHZxR differ