It is common to start with the registry to detect whether an item exists in the registry to determine if Office is installed, and to determine the specific version of the installation by using the registry information.
Because of the system, registry corruption, installation package and so on, the method of reading the registry is not reliable.
When the result of the registry detection is not installed, then to create an instance of Excel, if the creation is successful, then the description is installed.
Some people will ask, why not start directly to create an instance, my answer is to create an Excel instance of memory consumption, the registry is valid when the detection is sufficient.
//---------------------------------------------------------------------------
Doesexcelexist
Determine if Excel is installed
//---------------------------------------------------------------------------
function BOOL doesexcelexist ()
BOOL Bresult;
Begin
Regdb_options = regdb_options & ~regdb_option_wow64_64key;
Regdbsetdefaultroot (HKEY_LOCAL_MACHINE);
if (Regdbkeyexist ("Software\\wow6432node\\microsoft\\office\\excel") <0) Then
_out ("System does not has Excel, now check the system.");
if (Regdbkeyexist ("Software\\microsoft\\office\\excel") <0) Then
_out ("System does not has Excel too, now check is could create Excel object.");
if (! Createexcelobject ()) Then
_out ("So this system does not has Excel, return false.");
Bresult = FALSE;
Else
_out ("So this system has Excel, return true.");
Bresult = TRUE;
endif
Else
_out ("System has Excel, return.");
Bresult = TRUE;
endif
Else
_out ("System with Excel, return.");
Bresult = TRUE;
endif
Regdb_options = Regdb_options | Regdb_option_wow64_64key;
return bresult;
End
//---------------------------------------------------------------------------
Createexcelobject
Create an instance of Excel
Determine whether Excel is installed by success or not
//---------------------------------------------------------------------------
function BOOL Createexcelobject ()
OBJECT Excelobj;
Begin
Set excelobj = CreateObject ("Excel.Application");//Create an Excel object
if (IsObject (excelobj) = FALSE) Then
_out ("Create Excel object failed.");
Set excelobj = Nothing;
return FALSE;
endif
_out ("Create Excel object Successe.");
Set excelobj = Nothing;
return TRUE;
End
InstallShield How to do Excel installation or not detection