stas Sun Oct 19 06:22:21 2003 EDT Modified files: /php-src/win32 php_registry.h registry.c Log: Add function for getting php.ini path from registry Index: php-src/win32/php_registry.h diff -u php-src/win32/php_registry.h:1.3 php-src/win32/php_registry.h:1.4 --- php-src/win32/php_registry.h:1.3 Sat Aug 4 21:42:48 2001 +++ php-src/win32/php_registry.h Sun Oct 19 06:22:21 2003 @@ -3,5 +3,6 @@ void UpdateIniFromRegistry(char *path TSRMLS_DC); +char *GetIniPathFromRegistry(); #endif /* PHP_REGISTRY_H */ Index: php-src/win32/registry.c diff -u php-src/win32/registry.c:1.12 php-src/win32/registry.c:1.13 --- php-src/win32/registry.c:1.12 Mon Oct 14 08:05:09 2002 +++ php-src/win32/registry.c Sun Oct 19 06:22:21 2003 @@ -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; } @@ -85,4 +87,24 @@ } 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; }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php