Resolve path of Excel

♀尐吖头ヾ 提交于 2019-12-12 17:15:53

问题


Actually I intended to ask the following question:

For an executable that lies in a directory defined in %PATH%, how can I find out in which of these directory it is found?

because I need to run Excel from C# using Process.Run(...), and just indicating "Excel" works fine: Windows seems to know where to find it. However I need to provide the appropriate working directory, too.

But in the meantime I found out that Microsoft Office is not even in the %PATH%, Windows apparently resolves it in another way.

So how could I use or mimic this functionality from Windows to get the directory containing excel?

Update: Besides the suggestion of Ruel, is there a straighter way to achieve this? I know that Windows is able to resolve the path in some way, so I'd like to reuse this functionality if possible.

Any idea?


回答1:


Fetch it from the registry: HKLM\SOFTWARE\Microsoft\Office\(VERSION)\Excel\InstallRoot for the VERSION it can be 10.0 11.0 etc. You can detect it by checking if there's a subkey Excel in it.



来源:https://stackoverflow.com/questions/3831028/resolve-path-of-excel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!