Commit bc2e6319 authored by Guido van Rossum's avatar Guido van Rossum

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.
parent f8c684d3
......@@ -59,27 +59,46 @@ getpythonregpath(HKEY keyBase, BOOL bWin32s)
RegQueryInfoKey(newKey, NULL, NULL, NULL, NULL, 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 */
numEntries = 1;
dataSize = 511;
}
if (numEntries) {
dataBuf = malloc(dataSize);
// on NT, datasize is unicode - ie, 2xstrlen,
// even when ascii string returned.
// presumably will be 1xstrlen on 95/win3.1
// Additionally, win32s doesnt work as expected, so
// the specific strlen() is required for 3.1.
rc = RegQueryValue(newKey, "", dataBuf, &dataSize);
/* Loop over all subkeys. */
/* Win32s doesnt know how many subkeys, so we do
it twice */
char keyBuf[MAX_PATH+1];
int index = 0;
int off = 0;
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 (strlen(dataBuf)==0)
free(dataBuf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment