pepr
asked on
How can I get the full path to the MS Excel (Excel.exe) from the registry?
Hi,
How can I reliably get the full path to the Excel executable from the registry? The main goal is to get the detailed information about the version from the Excel.exe.
So far, I was successfull using the following approach, but it is not ideal, and there could be something better (symbolically, simplified):
Is the HKCR\CLSID\{...}\LocalServ er the good or the best way to get somehow the path to the Excel.exe? Can the path with shortened subdir names be expanded to full path? (I would like to include it to the error log if anything wrong happens.)
Thanks for your time and experience,
Petr
How can I reliably get the full path to the Excel executable from the registry? The main goal is to get the detailed information about the version from the Excel.exe.
So far, I was successfull using the following approach, but it is not ideal, and there could be something better (symbolically, simplified):
// Get the CLSID of the Excel.
RegOpenKeyEx(HKEY_CLASSES_ROOT, TEXT("Excel.Application\\CLSID"), 0, KEY_READ, &hKey);
RegQueryValueEx(hKey, TEXT(""), NULL, &ValueType, buf, &buflen);
// I have got the value "{00024500-0000-0000-C000-000000000046}" for Excel 2007 in buf.
// Get the LocalServer value.
RegOpenKeyEx(HKEY_CLASSES_ROOT, "CLSID\\" + buf + "\\LocalServer", 0, KEY_READ, &hKey);
// I have got the value "C:\PROGRA~2\MICROS~1\Office12\EXCEL.EXE /automation"
// Notice the shortened directory names.
[Remove the option /automation and text whether the file exist -- I want to check if the file physically
exists (not only to check that the info is present in the registry).]
[call the GetFileVersionInfo() for the filename (version.lib must be linked).]
// I get the string like "12.0.6557.5000"
Is the HKCR\CLSID\{...}\LocalServ
Thanks for your time and experience,
Petr
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help.
ASKER
For others, I have found the http://support.microsoft.com/kb/240794/en-us that uses basically the same approach as I did, but with the HKEY_CLASSES_ROOT is replaced by HKEY_LOCAL_MACHINE\Softwar