We have a legacy perl
code base that includes the below line:
use Win32::OLE::Const 'Microsoft Excel';
This has worked traditionally but is not working on newer 64-bit installations, such as Windows 10.
The error appears to be in the OLE.xs
source as below, but I have a limited understanding of Windows functions and XS
in general.
err = RegQueryValueA(hKeyLangid, "win32", szFile, &cbFile);
If this query fails, it never calls Win32::OLE::Const::_Typelib
which is the function that stores the result. Checking my registry, the keys are indeed Win64
and not win32
. Other keys that worked either have just win32
or both.
Is there a way to resolve this issue without editing the legacy module? It is widely used and any changes would involve some risk so I'm looking at alternatives first.
I'm aware we can do the below, but it doesn't stop the other Win32::OLE::Const
line causing an error if it's not removed.
my $Excel = Win32::OLE->new('Excel.Application', 'Quit');
my $xl = Win32::OLE::Const->Load($Excel);