From: "Mark Hammond" <MHammond@skippinet.com.au>

Date: Fri, 4 Oct 1996 09:08:19 +1000

A couple of things.  As I mentioned a while back, I have made the
changes to the registry support, in getpath_nt.c.  To recap, there can be:
...\pythonpath = default core Pythonpath
...\pythonpath\Pythonwin = c:\somewhere
etc.

The code simply appends them all.  The order can not be guaranteed
(registry limitation) but the "default" is always at the end.

The main reasons for change were the length of the path, but mainly
so an uninstaller can do the right thing.
This commit is contained in:
Guido van Rossum 1996-10-21 14:40:30 +00:00
parent f8c684d32c
commit bc2e6319cb
1 changed files with 35 additions and 16 deletions

View File

@ -59,27 +59,46 @@ getpythonregpath(HKEY keyBase, BOOL bWin32s)
RegQueryInfoKey(newKey, NULL, NULL, NULL, NULL, NULL, NULL, RegQueryInfoKey(newKey, NULL, NULL, NULL, NULL, NULL, NULL,
&numEntries, &nameSize, &dataSize, NULL, NULL ); &numEntries, &nameSize, &dataSize, NULL, NULL );
} }
if (numEntries==0) {
if (newKey)
CloseHandle(newKey);
if ((rc=RegOpenKey(keyBase, "Software\\Python\\PythonPath",
&newKey))==ERROR_SUCCESS) {
RegQueryInfoKey(newKey, NULL, NULL, NULL, NULL, NULL, NULL,
&numEntries, &nameSize, &dataSize, NULL, NULL );
}
}
if (bWin32s && numEntries==0 && dataSize==0) { /* must hardcode for Win32s */ if (bWin32s && numEntries==0 && dataSize==0) { /* must hardcode for Win32s */
numEntries = 1; numEntries = 1;
dataSize = 511; dataSize = 511;
} }
if (numEntries) { if (numEntries) {
dataBuf = malloc(dataSize); /* Loop over all subkeys. */
// on NT, datasize is unicode - ie, 2xstrlen, /* Win32s doesnt know how many subkeys, so we do
// even when ascii string returned. it twice */
// presumably will be 1xstrlen on 95/win3.1 char keyBuf[MAX_PATH+1];
// Additionally, win32s doesnt work as expected, so int index = 0;
// the specific strlen() is required for 3.1. int off = 0;
rc = RegQueryValue(newKey, "", dataBuf, &dataSize); for(index=0;;index++) {
long reqdSize = 0;
DWORD rc = RegEnumKey(newKey, index, keyBuf,MAX_PATH+1);
if (rc) break;
rc = RegQueryValue(newKey, keyBuf, NULL, &reqdSize);
if (rc) break;
if (bWin32s && reqdSize==0) reqdSize = 512;
dataSize += reqdSize + 1; /* 1 for the ";" */
}
dataBuf = malloc(dataSize+1);
if (dataBuf==NULL) return NULL; /* pretty serious? Raise error? */
/* Now loop over, grabbing the paths. Subkeys before main library */
for(index=0;;index++) {
int adjust;
long reqdSize = dataSize;
DWORD rc = RegEnumKey(newKey, index, keyBuf,MAX_PATH+1);
if (rc) break;
rc = RegQueryValue(newKey, keyBuf, dataBuf+off, &reqdSize);
if (rc) break;
adjust = strlen(dataBuf+off);
dataSize -= adjust;
off += adjust;
dataBuf[off++] = ';';
dataBuf[off] = '\0';
dataSize--;
}
/* Additionally, win32s doesnt work as expected, so
the specific strlen() is required for 3.1. */
rc = RegQueryValue(newKey, "", dataBuf+off, &dataSize);
if (rc==ERROR_SUCCESS) { if (rc==ERROR_SUCCESS) {
if (strlen(dataBuf)==0) if (strlen(dataBuf)==0)
free(dataBuf); free(dataBuf);