How to get Excel version and macro security level

Microsoft recently violated our long-standing (and officially recommended by them) code to read the version of Excel and its current omacro security level.

What was used for work:

// Get the program associated with workbooks, e.g. "C:\Program Files\...\Excel.exe"
SHELLAPI.FindExecutable( 'OurWorkbook.xls', ...) 

// Get the version of the .exe (from it Properties...)
WINDOWS.GetFileVersionInfo()

// Use the version number to access the registry to determine the security level
// '...\software\microsoft\Office\' + VersionNumber + '.0\Excel\Security'

(I was always surprised that the security level for many years was in an unprotected registry entry ...)

In Office 2010, .xls files are now associated with the "Microsoft Application Virtualization DDE Launcher" or sftdde.exe. The version number of this exe is obviously not a version of Excel.

My question is:

, Excel ( OLE CreateOLEObject ( "Excel.Application" )), , , , Excel 2003?

+3
2

function GetExcelPath: string;
begin
  result := '';
  with TRegistry.Create do
    try
      RootKey := HKEY_LOCAL_MACHINE;
      if OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe', false) then
        result := ReadString('Path') + 'excel.exe';
    finally
      Free;
    end;
end;

excel.exe. GetFileVersionInfo, .

, .

+4

OLE CreateOLEObject ('Excel.Application'))

Excel , . . , Microsoft Process Monitor, , Windows Excel, .

HKEY_CLASSES_ROOT\ , "Excel.Application."

, Excel 2013, HKEY_CLASSES_ROOT\Excel.Application.15

Excel 2003 Excel 2010, XLSX , .

HKEY_CLASSES_ROOT\Excel.Application.12 HKEY_CLASSES_ROOT\Excel.Application.14

, , .

: HKEY_CLASSES_ROOT\Excel.Application\CurVer " " Excel, , " ", , Excels. , , , , , Excel - .

, excel CLSID. HKEY_CLASSES_ROOT\Excel.Application.15\CLSID, - , {00024500-0000-0000-C000-000000000046} - .

- HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer ( )

- , - C:\PROGRA~1\MICROS~1\Office15\EXCEL.EXE /automation

- . ( , ), . , , .

, exe. - , - Excel.

+1

Source: https://habr.com/ru/post/1760195/


All Articles