我需要能够从我正在开发的一些.NET代码中检测我在我的机器上安装的Excel版本.我目前正在使用Application.Version,但它没有提供有关Service Pack的信息.
@H_502_9@
我最好避开这样的事情:
http://www.mvps.org/access/api/api0065.htm
托管代码欢迎!
Public Shared Function GetExcelVersion() As Integer Dim excel As Object = Nothing Dim ver As Integer = 0 Dim build As Integer Try excel = CreateObject("Excel.Application") ver = excel.Version build = excel.Build Catch ex As Exception 'Continue to finally sttmt Finally Try Marshal.ReleaseComObject(excel) Catch End Try GC.Collect() End Try Return ver End Function
如果未找到excel,则返回0.