|
-
Jun 4th, 2007, 10:42 PM
#1
Thread Starter
Member
[RESOLVED] Inno Vista OS Only Message
Hi!
I need to display a brief security message to vista users only at the end of the installation, Similar to InfoAfterFile=
However I was wanting to only bother the user with this if he/she is using a vista OS, is there anyway to use an IF statement or something to accomplish this?
-
Jun 4th, 2007, 11:10 PM
#2
Re: Inno Vista OS Only Message
You can do it something like this:
Code:
[Code ]
var s: Integer;
function DisplayMsg(Param: String): String;
begin
s := InstallOnThisVersion('0','6');
if s = 0 then MsgBox('Hello.', mbInformation, MB_OK);
end;
Check the Inno Setup Documentation on more about the code section.
-
Jun 4th, 2007, 11:44 PM
#3
Thread Starter
Member
Re: Inno Vista OS Only Message
hey thanks for the example, I also looked through some other code snippets etc. Unfortunately your code didnt do anything... on both an XP machine and a Vista machine... Im going to keep digging in the meantime.
-
Jun 5th, 2007, 12:04 AM
#4
Thread Starter
Member
Re: Inno Vista OS Only Message
Once the function DisplayMsg is in place, Do I have to call it from somewhere else in the inno script like you would VB ? I tried modifying the code to simply resturn the value of S without an IF statement and it still didnt show anything..
Code:
[Code ]
var s: Integer;
function DisplayMsg(Param: String): String;
begin
s := InstallOnThisVersion('0','6');
MsgBox(s, mbInformation, MB_OK);
end;
-
Jun 5th, 2007, 01:13 AM
#5
Re: Inno Vista OS Only Message
Yes, you have to call it from inside your script. Like any other language or script, a function does nothing unless it is actually called.
-
Jun 5th, 2007, 01:27 AM
#6
Re: Inno Vista OS Only Message
You can also use it with Inno Setup Events: Probably the best one to use is function GetCustomSetupExitCode: Integer;
Code:
The Pascal script can contain several event functions which are called at appropriate times.
Setup event functions
Setup supports following event functions:
function InitializeSetup(): Boolean;
Called during Setup's initialization. Return False to abort Setup, True otherwise.
procedure InitializeWizard();
Use this event function to make changes to the wizard or wizard pages at startup. You can't use the InitializeSetup event function for this since at the time it is triggered, the wizard form does not yet exist.
procedure DeinitializeSetup();
Called just before Setup terminates. Note that this function is called even if the user exits Setup before anything is installed.
procedure CurStepChanged(CurStep: TSetupStep);
You can use this event function to perform your own pre-install and post-install tasks.
Called with CurStep=ssInstall just before the actual installation starts, with CurStep=ssPostInstall just after the actual installation finishes, and with CurStep=ssDone just before Setup terminates after a successful install.
function NextButtonClick(CurPageID: Integer): Boolean;
Called when the user clicks the Next button. If you return True, the wizard will move to the next page; if you return False, it will remain on the current page (specified by CurPageID).
Note that this function is called on silent installs as well, even though there is no Next button that the user can click. Setup instead simulates "clicks" on the Next button. On a silent install, if your NextButtonClick function returns False prior to installation starting, Setup will exit automatically.
function BackButtonClick(CurPageID: Integer): Boolean;
Called when the user clicks the Back button. If you return True, the wizard will move to the previous page; if you return False, it will remain on the current page (specified by CurPageID).
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
Called when the user clicks the Cancel button or clicks the window's Close button. The Cancel parameter specifies whether normal cancel processing should occur; it defaults to True. The Confirm parameter specifies whether an "Exit Setup?" message box should be displayed; it usually defaults to True. If Cancel is set to False, then the value of Confirm is ignored.
function ShouldSkipPage(PageID: Integer): Boolean;
The wizard calls this event function to determine whether or not a particular page (specified by PageID) should be shown at all. If you return True, the page will be skipped; if you return False, the page may be shown.
Note: This event function isn't called for the wpWelcome, wpPreparing, and wpInstalling pages, nor for pages that Setup has already determined should be skipped (for example, wpSelectComponents in an install containing no components).
procedure CurPageChanged(CurPageID: Integer);
Called after a new wizard page (specified by CurPageID) is shown.
function CheckPassword(Password: String): Boolean;
If Setup finds the CheckPassword event function in the Pascal script, it automatically displays the Password page and calls CheckPassword to check passwords. Return True to accept the password and False to reject it.
To avoid storing the actual password inside the compiled [Code ] section which is stored inside Setup, you should use comparisons by hash only: calculate the MD5 hash of your password yourself and then compare that to GetMD5OfString(Password). This way the actual value of the password remains protected.
Note: if you have a CheckPassword event function and your users run Setup with both the "/PASSWORD=" and "/SILENT" command line parameters set, your CheckPassword function will be called *before* any other event function is called, including InitializeSetup.
function NeedRestart(): Boolean;
Return True to instruct Setup to prompt the user to restart the system at the end of a successful installation, False otherwise.
function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
If Setup finds the UpdateReadyMemo event function in the Pascal script, it is called automatically when the Ready to Install wizard page becomes the active page. It should return the text to be displayed in the settings memo on the Ready to Install wizard page as a single string with lines separated by the NewLine parameter. Parameter Space contains a string with spaces. Setup uses this string to indent settings. The other parameters contain the (possibly empty) strings that Setup would have used as the setting sections. The MemoDirInfo parameter for example contains the string for the Selected Directory section.
procedure RegisterPreviousData(PreviousDataKey: Integer);
To store user settings entered on custom wizard pages, place a RegisterPreviousData event function in the Pascal script and call SetPreviousData(PreviousDataKey, ...) inside it, once per setting.
function CheckSerial(Serial: String): Boolean;
If Setup finds the CheckSerial event function in the Pascal script, a serial number field will automatically appear on the User Info wizard page (which must be enabled using UserInfoPage=yes in your [Setup] section!). Return True to accept the serial number and False to reject it. When using serial numbers, it's important to keep in mind that since no encryption is used and the source code to Inno Setup is freely available, it would not be too difficult for an experienced individual to remove the serial number protection from an installation. Use this only as a convienience to the end user and double check the entered serial number (stored in the {userinfoserial} constant) in your application.
function GetCustomSetupExitCode: Integer;
Return a non zero number to instruct Setup to return a custom exit code. This function is only called if Setup was successfully run to completion and the exit code would have been 0. Also see Setup Exit Codes.
Uninstall event functions
Uninstall supports following event functions:
function InitializeUninstall(): Boolean;
Return False to abort Uninstall, True otherwise.
procedure DeinitializeUninstall();
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
function UninstallNeedRestart(): Boolean;
Return True to instruct Uninstall to prompt the user to restart the system at the end of a successful uninstallation, False otherwise.
Constants
Here's the list of constants used by these functions:
CurStep values
ssInstall, ssPostInstall, ssDone
CurUninstallStep values
usAppMutexCheck, usUninstall, usPostUninstall, usDone
CurPageID values for predefined wizard pages
wpWelcome, wpLicense, wpPassword, wpInfoBefore, wpUserInfo, wpSelectDir, wpSelectComponents, wpSelectProgramGroup, wpSelectTasks, wpReady, wpPreparing, wpInstalling, wpInfoAfter, wpFinished
None of these functions are required to be present in a Pascal script.
-
Jun 5th, 2007, 01:32 AM
#7
Thread Starter
Member
Re: Inno Vista OS Only Message
Ok, well that makes sense. Ive scoured through many example scripts, but I cannot find where or how I would call function DisplayMsg. Ive created a test script below just to test this function... Please help!
Code:
[Setup]
AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=c:\
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
[Code ]
var s: Integer;
function DisplayMsg(Param: String): String;
begin
s := InstallOnThisVersion('0','6');
if s = 0 then MsgBox('Hello. this is VISTA', mbInformation, MB_OK);
end;
Last edited by Cbyte; Jun 5th, 2007 at 01:43 AM.
-
Jun 5th, 2007, 01:37 AM
#8
Re: Inno Vista OS Only Message
Try using a Inno Setup Event: You must remove the space from [code ]. I just put that there so that the Forum would not confuse it with it's keywords.
Code:
[code ]
var s: Integer;
function GetCustomSetupExitCode: Integer;
begin
s := InstallOnThisVersion('0','6');
if s = 0 then MsgBox('Hello. this is VISTA', mbInformation, MB_OK);
end;
-
Jun 5th, 2007, 01:44 AM
#9
Thread Starter
Member
Re: Inno Vista OS Only Message
Yeh i made sure to remove the space
My code now looks like this... run it on my test vista machine and nothing pops up.
Code:
[Setup]
AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=c:\
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
[code ]
var s: Integer;
function GetCustomSetupExitCode: Integer;
begin
s := InstallOnThisVersion('0','6');
if s = 0 then MsgBox('Hello. this is VISTA', mbInformation, MB_OK);
end;
-
Jun 5th, 2007, 01:47 AM
#10
Re: Inno Vista OS Only Message
Simple comment everything out and just put the msgbox statement there to see if the event is being called at all.
-
Jun 5th, 2007, 01:53 AM
#11
Thread Starter
Member
Re: Inno Vista OS Only Message
Did that, and the msgbox makes an appearance
-
Jun 5th, 2007, 01:55 AM
#12
Re: Inno Vista OS Only Message
Ok, then the value of s is not zero for Vista. Uncomment the line where s is set and Put s in the msgbox and let me know what that is.
-
Jun 5th, 2007, 01:57 AM
#13
Re: Inno Vista OS Only Message
I.E
Code:
function GetCustomSetupExitCode: Integer;
begin
s := InstallOnThisVersion('0','6');
MsgBox(s, mbInformation, MB_OK);
end;
-
Jun 5th, 2007, 02:01 AM
#14
Thread Starter
Member
Re: Inno Vista OS Only Message
I am pretty sure i found the solution
Code:
[Code ]
function GetCustomSetupExitCode: Integer;
begin
if InstallOnThisVersion('0,6', '0,0') = irInstall then MsgBox('Hello. this is VISTA', mbInformation, MB_OK);
end;
I tested it on Vista and msgbox appeared, tested it on XP and it didnt appear. I think in your code the version numbers were just the wrong way around.
-
Jun 5th, 2007, 02:04 AM
#15
Re: Inno Vista OS Only Message
Great I will change that also
-
Jun 5th, 2007, 02:14 AM
#16
Thread Starter
Member
Re: Inno Vista OS Only Message
Thanks heaps for your help, I am now on my way.... Cheers. Gave you a rating and will mark this as resolved
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
|