mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Add function for getting php.ini path from registry
This commit is contained in:
parent
df033b58a0
commit
3e828db413
2 changed files with 24 additions and 1 deletions
|
@ -3,5 +3,6 @@
|
||||||
|
|
||||||
|
|
||||||
void UpdateIniFromRegistry(char *path TSRMLS_DC);
|
void UpdateIniFromRegistry(char *path TSRMLS_DC);
|
||||||
|
char *GetIniPathFromRegistry();
|
||||||
|
|
||||||
#endif /* PHP_REGISTRY_H */
|
#endif /* PHP_REGISTRY_H */
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "php_ini.h"
|
#include "php_ini.h"
|
||||||
|
|
||||||
|
#define PHP_REGISTRY_KEY "SOFTWARE\\PHP"
|
||||||
|
|
||||||
void UpdateIniFromRegistry(char *path TSRMLS_DC)
|
void UpdateIniFromRegistry(char *path TSRMLS_DC)
|
||||||
{
|
{
|
||||||
char *p, *orig_path;
|
char *p, *orig_path;
|
||||||
HKEY MainKey;
|
HKEY MainKey;
|
||||||
char *strtok_buf = NULL;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,3 +88,23 @@ void UpdateIniFromRegistry(char *path TSRMLS_DC)
|
||||||
RegCloseKey(MainKey);
|
RegCloseKey(MainKey);
|
||||||
efree(orig_path);
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue