Grazie all'aiuto di spikexx84, sono riuscito ad arrivare ad una soluzione, creando un'installazione client/server pulita ed essenziale. Riporto di seguito, per chi avesse bisogno di qualche spunto, il codice del mio elaborato, al quale sono arrivato insieme a spikexx84 e con l'ausilio dell'help di InnoSetup (per i dettagli leggete, oltre ai post della presente discussione, anche i punti descritti nelle due discussioni "[Inno Setup] Richiesta di più path in un'installazione client/server" e "[Inno Setup] Controllare l'esistenza o i valori delle chiavi di registro").
Grazie ancora di tutto spikexx84!! Saper utilizzare questo bel programma qual è InnoSetup, deve dare tante soddisfazioni!!
Ecco di seguito il codice (tenete conto che sono un programmatore novizio di InnoSetup, perciò dovessero esserci errori o metodi migliori per fare qualcosa, scusatemi in anticipo).
[Setup]
AppId={{xxxx-yyyy-zzzz}
AppName=AppName
AppVerName=AppName 1.0
DefaultDirName={pf}\AppName 1.0
DefaultGroupName=AppName 1.0
AllowNoIcons=yes
LicenseFile=license.txt
OutputBaseFilename=Setup_1.0
Compression=lzma
SolidCompression=true
AppendDefaultDirName=true
VersionInfoVersion=1.0
VersionInfoProductName=AppName
VersionInfoProductVersion=1.0
AppVersion=1.0
[Languages]
Name: english; MessagesFile: compiler:Default.isl
[Files]
Source: File1.mdb; DestDir: {code:LeggiPathDati}; Check: InstallaDati
Source: File2.xls; DestDir: {code:LeggiPathDati}; Check: InstallaDati
Source: File3.xls; DestDir: {code:LeggiPathDati}; Check: InstallaDati
Source: library_1_0.dll; DestDir: {app}; Flags: regserver restartreplace ignoreversion
Source: RegMWComUtil_silent.bat; DestDir: {app}; Attribs: hidden; Flags: ignoreversion; Check: InstallaMCR
Source: VB_DCOM_MDAC_JET_AutoSetup.exe; DestDir: {tmp}; Flags: ignoreversion deleteafterinstall skipifsourcedoesntexist
Source: dotnetfx3.exe; DestDir: {tmp}; Flags: ignoreversion deleteafterinstall skipifsourcedoesntexist onlyifdoesntexist; Check: InstallaDotNetFramework
Source: vcredist_x86.exe; DestDir: {tmp}; Flags: ignoreversion deleteafterinstall skipifsourcedoesntexist; Check: InstallaMCR
Source: MCRInstaller.exe; DestDir: {tmp}; Flags: ignoreversion deleteafterinstall skipifsourcedoesntexist onlyifdoesntexist; Check: InstallaMCR
[Icons]
Name: {group}\File1; Filename: {code:LeggiPathDati}\File1.mdb
Name: {group}\File2; Filename: {code:LeggiPathDati}\File2.xls
Name: {group}\File3; Filename: {code:LeggiPathDati}\File3.xls
Name: {group}\{cm:UninstallProgram,AppName 1.0}; Filename: {uninstallexe}
[Run]
Filename: {tmp}\VB_DCOM_MDAC_JET_AutoSetup.exe; Parameters: /NORESTART /VERYSILENT; WorkingDir: {tmp}; Flags: skipifdoesntexist
Filename: {tmp}\dotnetfx3.exe; WorkingDir: {tmp}; Flags: skipifdoesntexist; Check: InstallaDotNetFramework
Filename: {tmp}\vcredist_x86.exe; Parameters: /NORESTART /VERYSILENT; WorkingDir: {tmp}; Flags: skipifdoesntexist; Check: InstallaMCR
Filename: {tmp}\MCRInstaller.exe; WorkingDir: {tmp}; Flags: skipifdoesntexist; Check: InstallaMCR
Filename: {app}\RegMWComUtil_silent.bat; Flags: runhidden runascurrentuser; Check: InstallaMCR
Di seguito il testo da inserire nella sezione [code]:
var
DotNetChecked: Boolean;
MCRChecked: Boolean;
b_InstallaMCR: Boolean;
b_InstallaDotNet: Boolean;
DWord: Cardinal;
function InstallaDotNetFramework: Boolean;
begin
if Not DotNetChecked then
begin
if (RegQueryDWordValue(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0','Install',DWord) And (DWord = 1)) Or (RegQueryDWordValue(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5','Install',DWord) And (DWord = 1)) then
begin
b_InstallaDotNet := False;
end
else
begin
b_InstallaDotNet := MsgBox('Setup has detected that .NET Framework 3.0 is not installed on this workstation. Without it some application components will not work properly. It is suggested to install it. Do you want to install .NET Framework 3.0?', mbConfirmation, MB_YESNO) = idYes;
end;
DotNetChecked := True;
end;
Result := b_InstallaDotNet;
end;
function InstallaMCR: Boolean;
begin
if Not MCRChecked then
begin
if RegKeyExists(HKEY_LOCAL_MACHINE,'SOFTWARE\MATLAB\MCRPathDir') then
begin
b_InstallaMCR := False
end
else
begin
b_InstallaMCR := MsgBox('Setup has detected that Matlab Component Runtime 7.11 is not installed on this workstation. Without it some application components will not work properly. It is suggested to install it. Do you want to install Matlab Component Runtime 7.11?', mbConfirmation, MB_YESNO) = idYes;
end;
MCRChecked := True;
end;
Result := b_InstallaMCR;
end;
function Excel2003Installato: Boolean;
begin
if RegKeyExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Office\11.0\Excel') Or RegKeyExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Office\12.0\Excel') then
begin
Result := True;
end
else
begin
Result := False;
end;
end;
function Access2003Installato: Boolean;
begin
if RegKeyExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Office\11.0\Access') Or RegKeyExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Office\12.0\Access') then
begin
Result := True;
end
else
begin
Result := False;
end;
end;
function InitializeSetup: Boolean;
var
Version: TWindowsVersion;
S: String;
begin
GetWindowsVersionEx(Version);
// On Windows XP, check for SP3
if Version.NTPlatform and
(Version.Major = 5) and
(Version.Minor = 1) and
(Version.ServicePackMajor < 3) then
begin
SuppressibleMsgBox('When running on Windows XP, Service Pack 3 is required.',
mbCriticalError, MB_OK, MB_OK);
Result := False;
Exit;
end;
// Check for Microsoft Excel
if Excel2003Installato = False then
begin
SuppressibleMsgBox('Microsoft Excel 2003/2007 is required for application execution.',
mbCriticalError, MB_OK, MB_OK);
Result := False;
Exit;
end;
// Check for Microsoft Access
if Access2003Installato = False then
begin
SuppressibleMsgBox('Microsoft Access 2003/2007 is required for application execution.',
mbCriticalError, MB_OK, MB_OK);
Result := False;
Exit;
end;
// Check for .NET Framework
InstallaDotNetFramework;
// Check for MCR
InstallaMCR;
Result := True;
end;
var
s_PathDati : string;
b_InstallaDati : boolean;
function LeggiPathDati(Param: String): String;
begin
Result:= s_PathDati;
end;
function InstallaDati(): boolean;
begin
Result:= b_InstallaDati;
end;
var
Label1: TLabel;
Label2: TLabel;
lbl_description: TLabel;
lbl_folder: TLabel;
radio_local: TRadioButton;
radio_client: TRadioButton;
radio_server: TRadioButton;
txt_dataPath: TEdit;
btn_browsePath: TButton;
procedure InstallazioneLocal_Click(Sender: TObject);
begin
lbl_description.Caption := 'Choose this installation type if you will use the application only from this workstation.'
lbl_folder.Caption := 'Setup will install data files into the following local folder.';
end;
procedure InstallazioneClient_Click(Sender: TObject);
begin
lbl_description.Caption := 'Choose this installation type if you are installing the application on a client of a network.'
lbl_folder.Caption := 'Select shared folder containing data files.';
end;
procedure InstallazioneServer_Click(Sender: TObject);
begin
lbl_description.Caption := 'Choose this installation type if you are installing the application on a server and you want to share it with clients.'
lbl_folder.Caption := 'Setup will install data files into the following shared folder.';
end;
var
Directory: String;
procedure Sfoglia_Click(Sender: TObject);
begin
if BrowseForFolder('Select shared folder.', Directory, True) then
begin
txt_dataPath.text := Directory
end;
end;
{ ClientServer_NextkButtonClick }
function ClientServer_NextButtonClick(Page: TWizardPage): Boolean;
begin
if radio_local.Checked then
begin
s_PathDati := txt_dataPath.text
b_InstallaDati := True
end
else if radio_server.Checked then
begin
s_PathDati := txt_dataPath.text
b_InstallaDati := True
end
else
begin
b_InstallaDati := False
end;
Result := True;
end;
{ ClientServer_CreatePage }
function ClientServer_CreatePage(PreviousPageId: Integer): Integer;
var
Page: TWizardPage;
begin
Page := CreateCustomPage(
PreviousPageId,
'Select Installation Type and Data Location',
'What type of installation do you want to execute? Where should data files be installed/located?'
);
{ Label1 }
Label1 := TLabel.Create(Page);
with Label1 do
begin
Parent := Page.Surface;
Caption := 'Installation Type:';
Left := ScaleX(0);
Top := ScaleY(8);
Width := ScaleX(84);
Height := ScaleY(13);
end;
{ Label2 }
Label2 := TLabel.Create(Page);
with Label2 do
begin
Parent := Page.Surface;
Caption := 'To continue, click Next. If you would like to select a different folder, click Browse.';
Left := ScaleX(0);
Top := ScaleY(152);
Width := ScaleX(390);
Height := ScaleY(13);
end;
{ lbl_description }
lbl_description := TLabel.Create(Page);
with lbl_description do
begin
Parent := Page.Surface;
Caption := 'Choose this installation type if you will use the application only from this workstation.';
Left := ScaleX(192);
Top := ScaleY(32);
Width := ScaleX(202);
Height := ScaleY(61);
WordWrap := True;
end;
{ lbl_folder }
lbl_folder := TLabel.Create(Page);
with lbl_folder do
begin
Parent := Page.Surface;
Caption := 'Setup will install data files into the following local folder.';
Left := ScaleX(0);
Top := ScaleY(128);
Width := ScaleX(290);
Height := ScaleY(13);
end;
{ radio_local }
radio_local := TRadioButton.Create(Page);
with radio_local do
begin
Parent := Page.Surface;
Caption := 'Local';
Left := ScaleX(0);
Top := ScaleY(24);
Width := ScaleX(73);
Height := ScaleY(33);
Checked := True;
TabOrder := 0;
TabStop := True;
OnClick := @InstallazioneLocal_Click;
end;
{ radio_client }
radio_client := TRadioButton.Create(Page);
with radio_client do
begin
Parent := Page.Surface;
Caption := 'Client';
Left := ScaleX(0);
Top := ScaleY(48);
Width := ScaleX(73);
Height := ScaleY(33);
Checked := False;
TabOrder := 1;
OnClick := @InstallazioneClient_Click;
end;
{ radio_server }
radio_server := TRadioButton.Create(Page);
with radio_server do
begin
Parent := Page.Surface;
Caption := 'Server';
Left := ScaleX(0);
Top := ScaleY(72);
Width := ScaleX(73);
Height := ScaleY(33);
TabOrder := 2;
OnClick := @InstallazioneServer_Click;
end;
{ txt_dataPath }
txt_dataPath := TEdit.Create(Page);
with txt_dataPath do
begin
Parent := Page.Surface;
Left := ScaleX(0);
Top := ScaleY(178);
Width := ScaleX(337);
Height := ScaleY(21);
TabOrder := 3;
Text := ExpandConstant('{commondocs}\AppName Data')
end;
{ btn_browsePath }
btn_browsePath := TButton.Create(Page);
with btn_browsePath do
begin
Parent := Page.Surface;
Caption := 'Browse...';
Left := ScaleX(344);
Top := ScaleY(176);
Width := ScaleX(65);
Height := ScaleY(25);
TabOrder := 4;
OnClick := @Sfoglia_Click
end;
with Page do
begin
OnNextButtonClick := @ClientServer_NextButtonClick;
end;
Result := Page.ID;
end;
{ ClientServer_InitializeWizard }
procedure InitializeWizard();
begin
ClientServer_CreatePage(wpSelectDir);
end;
Ciao a tutti!!