none
Check if both Word 2010 and Word 2013 are installed RRS feed

  • Question

  • Hi,

    in my Application Setup (Inno Setup) I need to check if Word is installed and which version it is. I can accomplish the task with the following code:

    function fVersionWord(): Integer;
    var
      localWord : String;
      loaded: String;
    begin
        Result := 0;
        RegQueryStringValue( HKLM,'Software\Microsoft\Windows\CurrentVersion\App Paths\WinWord.exe','path',loaded );
        loaded:= AnsiUppercase(loaded)
        RegQueryStringValue( HKLM,'Software\Microsoft\Office\9.0\Word\InstallRoot','Path',localWord );
        if fileexists(localWord + '\WinWord.exe') then
    	if AnsiUppercase(localWord) = loaded then
    	   Result:=2000 //Word 2000
        localWord := '';
        RegQueryStringValue( HKLM,'Software\Microsoft\Office\10.0\Word\InstallRoot','Path',localWord );
        if fileexists(localWord + '\WinWord.exe') then
    	if AnsiUppercase(localWord) = loaded then
    	   Result := 2002 //Word 2002
        localWord := '';
        RegQueryStringValue( HKLM,'Software\Microsoft\Office\11.0\Word\InstallRoot','Path',localWord );
        if fileexists(localWord + '\WinWord.exe') then
    	if AnsiUppercase(localWord) = loaded then
    	   Result := 2003 //Word 2003
        localWord := '';
        RegQueryStringValue( HKLM,'Software\Microsoft\Office\12.0\Word\InstallRoot','Path',localWord );
        if fileexists(localWord + '\WinWord.exe') then
    	if AnsiUppercase(localWord) = loaded then
    	   Result := 2007 //Word 2007
        localWord := '';
        RegQueryStringValue( HKLM,'Software\Microsoft\Office\14.0\Word\InstallRoot','Path',localWord );
        if fileexists(localWord + '\WinWord.exe') then
    	if AnsiUppercase(localWord) = loaded then
    	   Result := 2010 //Word 2010
        localWord := '';
        RegQueryStringValue( HKLM,'Software\Microsoft\Office\15.0\Word\InstallRoot','Path',localWord );
        if fileexists(localWord + '\WinWord.exe') then
    	if AnsiUppercase(localWord) = loaded then
    	   Result := 2013 //Word 2013
    end;
    

    But I can't succed in detecting if the system has both Office 2010 and Office 2013/365 installed.

    The problem is that the "loaded" variable from HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\WinWord.exe,'path' is always the path of the word 2010 installation and when I check it against the "localWord" variable from HKLM\Software\Microsoft\Office\1X.0\Word\InstallRoot,'Path' it succed for Office 2010, but it fails for Office 2013 simple because it has a different installation path.

    I should be able to get from the Registry the value of HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\WinWord.exe,'path' for both word 2010 AND Word 2013.

    How?

    Thanks, Lauro

    Saturday, November 29, 2014 10:10 PM

Answers