-
Oct 27th, 2007, 11:21 AM
#1
Thread Starter
Addicted Member
[RESOLVED] How to determine the Office version programicaly using the INNO setup?
I have two types of Word add-ins – one for Word 2007 and another for other versions.
I use INNO setup for distribution package.
Is it possible to determine the Office version that installed on target machine and than to run the right installation file?
Thanks.
-
Oct 27th, 2007, 07:17 PM
#2
Re: How to determine the Office version programicaly using the INNO setup?
You can use the code section to get info from the registry on the version of Word that is installed then proceed to install the proper installation. I don't know the registry entries for Word but you can get them.
-
Oct 27th, 2007, 07:28 PM
#3
Re: How to determine the Office version programicaly using the INNO setup?
Here is the registry key
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office] You would need to enumerate thru this key to find all the versions of office that is installed on the machine and then enumerate thru each version key [11, 8, 9] to find the Word key name then you will know which version of Word is installed.
I think that this might be a better procedure done in an app that ran before the actual installation. This app would determine all the things that you need for your app to install and run correctly. You could have this app create an ini file that had all this information the launch the installation. The installation could read the ini file and install the proper installations.
This all could be done using Inno Setup making the installation look seamless.
On my machine the actual registry entry is at [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Word]
Last edited by randem; Oct 27th, 2007 at 07:32 PM.
-
Oct 31st, 2007, 05:37 PM
#4
Thread Starter
Addicted Member
Re: How to determine the Office version programicaly using the INNO setup?
On my C the office version registered in:
HKEY_CLASSES_ROOT/Word.Application/CurVer.
I tried to write the code that detects the Word Version and installes installs appropriate files but I failed to compile it. INNO returns en error "Class Type Expected” on the line with registry parameters.
Since this is the first time that I write such a code, I would like to ask you to take a look on my code.
Thanks.
[CODE]#define MyAppName "My Program"
#define MyAppVerName "My Program 1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"
[Setup]
AppName={#MyAppName}
AppVerName={#MyAppVerName}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
OutputDir=C:\Temp\6
OutputBaseFilename=example
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compilerefault.isl"
[Files]
Source: "C:\Program Files\Inno Setup 5\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion; Check: Office2007
Source: "C:\Program Files\Inno Setup 5\Examples\Sol.exe"; DestDir: "{app}"; Flags: ignoreversion; Check: PreviousOffice
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#MyAppName}}"; Flags: nowait postinstall skipifsilent
Code:
//Get office version
function IsOffice2007(): boolean;
var
success: boolean;
OfficeVer: cardinal;
begin
success := RegQueryDWordValue(HKEY_CLASSES_ROOT, 'Word.Application\CurVer', Word.Application.11' );
Result := success and (OfficeVer = Word.Application.11);
end;
//RETURNS OPPOSITE OF IsOffice2007 FUNCTION
function Office2007(): Boolean;
begin
Result := (IsOffice2007 = false);
end;
//RETURNS OPPOSITE OF not Office2007 FUNCTION
function PreviousOffice(): Boolean;
begin
Result := (IsOffice2007 = true);
end;
-
Oct 31st, 2007, 07:17 PM
#5
Re: How to determine the Office version programicaly using the INNO setup?
First the function needs four parameters and you only supplied three.
Then you are looking for a DWORD and what needs to be returned is a REG_SZ. So you are using the wrong function. Try using
function RegQueryStringValue(const RootKey: Integer; const SubKeyName, ValueName: String; var ResultStr: String): Boolean;
-
Nov 1st, 2007, 03:46 AM
#6
Re: How to determine the Office version programicaly using the INNO setup?
You could also just package two versions, one with 2007 version and one with pre-2007.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Nov 1st, 2007, 06:21 PM
#7
Thread Starter
Addicted Member
Re: How to determine the Office version programicaly using the INNO setup?
Of course, I can create two package versions, but I would like to create one generic version that installes appropreate add-in, depends on office version.
Meanwhle I tried:
Code:
success := RegQueryStringValue(HKEY_CLASSES_ROOT, 'Word.Application\CurVer', '', Word.Application.11 );
But I've got the error: Class Type expected.
It seems that the compiler does't accept values with dots (like Word.Application.11).
-
Nov 1st, 2007, 10:49 PM
#8
Re: How to determine the Office version programicaly using the INNO setup?
I has nothing to do with that, you MUST follow the directions of the code posted...
Code:
Prototype:
function RegQueryStringValue(const RootKey: Integer; const SubKeyName, ValueName: String; var ResultStr: String): Boolean;
Description:
Queries the specified REG_SZ- or REG_EXPAND_SZ-type value, and returns the data in ResultStr. Returns True if successful. When False is returned, ResultStr is unmodified.
Example:
var
Country: String;
begin
if RegQueryStringValue(HKEY_CURRENT_USER, 'Control Panel\International',
'sCountry', Country) then
begin
// Successfully read the value
MsgBox('Your country: ' + Country, mbInformation, MB_OK);
end;
end;
From these instructions your code should look something like
Code:
var
sWordVar: String;
begin
RegQueryStringValue(HKEY_CLASSES_ROOT, 'Word.Application\CurVer', 'Default', sWordVar)
end;
Then the value "Word.Application.11" should be returned
-
Nov 2nd, 2007, 08:23 AM
#9
Thread Starter
Addicted Member
Re: How to determine the Office version programicaly using the INNO setup?
Randem,
thanks a lot.
The problem is solved.
I use:
Code:
RegQueryStringValue(HKEY_CLASSES_ROOT, 'Word.Application\CurVer', '', sWordVar)
-
Apr 19th, 2012, 05:16 PM
#10
New Member
Re: How to determine the Office version programicaly using the INNO setup?
Originally Posted by alex30
Randem,
thanks a lot.
The problem is solved.
I use:
Code:
RegQueryStringValue(HKEY_CLASSES_ROOT, 'Word.Application\CurVer', '', sWordVar)
Sorry to resurrect an old thread, but I am attempting to understand this since I also would like to create an Inno installation routine which detects the version of Office someone is using. I have tried various iterations of the above code and can't seem to get things to work.
Alex30, could you please post all of the code you are using to do this?
My objective is simple...install file ABC if someone is using Office 2007. If someone is using Office 2010, install file DEF.
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|