summaryrefslogtreecommitdiff
path: root/win32/registry.c
diff options
context:
space:
mode:
authorDaniel Beulshausen <dbeu@php.net>2001-03-20 15:44:55 +0000
committerDaniel Beulshausen <dbeu@php.net>2001-03-20 15:44:55 +0000
commit1ba3c6d65d29d3218057eff47643ef684dac8cde (patch)
tree0e4a2b0ef8cc6c7b329f758dec92b9e7baf12ddf /win32/registry.c
parent1b07e7a6129d75fc5a07fbf08f5a44ed8084d7ac (diff)
downloadphp-git-1ba3c6d65d29d3218057eff47643ef684dac8cde.tar.gz
fix registry per directory values
# they never really worked for me before
Diffstat (limited to 'win32/registry.c')
-rw-r--r--win32/registry.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/win32/registry.c b/win32/registry.c
index ac34902af7..d18ce40b41 100644
--- a/win32/registry.c
+++ b/win32/registry.c
@@ -1,9 +1,5 @@
#include "php.h"
#include "php_ini.h"
-#include "php_registry.h"
-
-#define MAX_NAMEBUF_LEN 512
-#define MAX_VALUE_LEN 512
void UpdateIniFromRegistry(char *path)
{
@@ -53,23 +49,36 @@ void UpdateIniFromRegistry(char *path)
while (p) {
HKEY hKey;
- char namebuf[MAX_NAMEBUF_LEN], valuebuf[MAX_VALUE_LEN];
DWORD lType;
- DWORD namebuf_length=MAX_NAMEBUF_LEN, valuebuf_length=MAX_VALUE_LEN;
- DWORD i=0;
-
+ DWORD values = 0, max_name = 0, max_value = 0, i = 0;
+
if (p>path) {
*(p-1) = '\\'; /* restore the slash */
}
+
if (RegOpenKeyEx(MainKey, path, 0, KEY_READ, &hKey)!=ERROR_SUCCESS) {
break;
}
- while (RegEnumValue(hKey, i++, namebuf, &namebuf_length, NULL, &lType, valuebuf, &valuebuf_length)==ERROR_SUCCESS) {
- if (lType != REG_SZ) {
- continue;
+
+ if(RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &values, &max_name, &max_value, NULL, NULL) == ERROR_SUCCESS) {
+ LPTSTR namebuf = (LPTSTR)emalloc(max_name + 1);
+ PBYTE valuebuf = (PBYTE)emalloc(max_value);
+
+ while (i < values) {
+ DWORD namebuf_len = max_name + 1;
+ DWORD valuebuf_len = max_value;
+
+ RegEnumValue(hKey, i, namebuf, &namebuf_len, NULL, &lType, valuebuf, &valuebuf_len);
+
+ if ((lType == REG_SZ) || (lType == REG_EXPAND_SZ)) {
+ zend_alter_ini_entry(namebuf, namebuf_len + 1, valuebuf, valuebuf_len, PHP_INI_PERDIR, PHP_INI_STAGE_ACTIVATE);
+ }
+
+ i++;
}
- /*printf("%s -> %s\n", namebuf, valuebuf);*/
- zend_alter_ini_entry(namebuf, namebuf_length+1, valuebuf, valuebuf_length+1, PHP_INI_PERDIR, PHP_INI_STAGE_ACTIVATE);
+
+ efree(namebuf);
+ efree(valuebuf);
}
RegCloseKey(hKey);