How to get the list of all ODBC data sources available in my windows pc using PHP. I have tried using the below code. But getting empty. Could you please help.
define('HKEY_LOCAL_MACHINE', 0x80000002);
$computer = '.';
$reg = new COM("winmgmts:{impersonationLevel=impersonate}\\\\" . $computer . "\\root\\default:StdRegProv");
$key_path = 'SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers';
$sub_keys = array();
$reg->EnumKey(HKEY_LOCAL_MACHINE, $key_path, $sub_keys);
foreach($sub_keys as $sub_key){
echo $sub_key;
}
Finally I got the solution and its working fine.
define('HKEY_LOCAL_MACHINE', 0x80000002);
$computer = '.';
$reg = new COM("winmgmts:{impersonationLevel=impersonate}!\\\\$computer\\root\\default:StdRegProv");
$key_path = 'SOFTWARE\ODBC\ODBCINST.INI';
$sub_keys = new VARIANT();
$reg->EnumKey(HKEY_LOCAL_MACHINE, $key_path, $sub_keys);
foreach($sub_keys as $sub_key){
echo $sub_key . "\n";
}
User contributions licensed under CC BY-SA 3.0