summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2003-10-19 10:22:21 +0000
committerStanislav Malyshev <stas@php.net>2003-10-19 10:22:21 +0000
commit3e828db413a1488a3ac50467d80a022542b932f7 (patch)
treea442627331ccdd1a9319133e4f5b3a9238391b01
parentdf033b58a00dba729838b4ad0d55fcd8bdcb0fda (diff)
downloadphp-git-3e828db413a1488a3ac50467d80a022542b932f7.tar.gz
Add function for getting php.ini path from registry
-rw-r--r--win32/php_registry.h1
-rw-r--r--win32/registry.c24
2 files changed, 24 insertions, 1 deletions
diff --git a/win32/php_registry.h b/win32/php_registry.h
index fe7c1fddd5..2b111dbb8b 100644
--- a/win32/php_registry.h
+++ b/win32/php_registry.h
@@ -3,5 +3,6 @@
void UpdateIniFromRegistry(char *path TSRMLS_DC);
+char *GetIniPathFromRegistry();
#endif /* PHP_REGISTRY_H */
diff --git a/win32/registry.c b/win32/registry.c
index 06e6bc0548..c2f4666587 100644
--- a/win32/registry.c
+++ b/win32/registry.c
@@ -1,13 +1,15 @@
#include "php.h"
#include "php_ini.h"
+#define PHP_REGISTRY_KEY "SOFTWARE\\PHP"
+
void UpdateIniFromRegistry(char *path TSRMLS_DC)
{
char *p, *orig_path;
HKEY MainKey;
char *strtok_buf = NULL;
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\PHP\\Per Directory Values", 0, KEY_READ, &MainKey)!=ERROR_SUCCESS) {
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, PHP_REGISTRY_KEY "\\Per Directory Values", 0, KEY_READ, &MainKey)!=ERROR_SUCCESS) {
return;
}
@@ -86,3 +88,23 @@ void UpdateIniFromRegistry(char *path TSRMLS_DC)
RegCloseKey(MainKey);
efree(orig_path);
}
+
+#define PHPRC_REGISTRY_NAME "IniFilePath"
+
+char *GetIniPathFromRegistry()
+{
+ char *reg_location = NULL;
+ HKEY hKey;
+
+ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, PHP_REGISTRY_KEY, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
+ reg_location = emalloc(MAXPATHLEN+1);
+ DWORD buflen = MAXPATHLEN;
+ if(RegQueryValueEx(hKey, PHPRC_REGISTRY_NAME, 0, NULL, reg_location, &buflen) != ERROR_SUCCESS) {
+ efree(reg_location);
+ reg_location = NULL;
+ return reg_location;
+ }
+ RegCloseKey(hKey);
+ }
+ return reg_location;
+}