0

I export a function from dll like this:

function IsClientLaunched : Boolean;                                                  
external 'IsClientStarted@files:IsStart.dll stdcall setuponly';

I need this function to check if my application is already running or not. It returns True if it's running and false if it's not. What I need to do is depending on the result of that function I have to show the custom window with the custom message and 2 buttons: Continue and Cancel. So if I close the app and press Continue then the installation process goes on. If I press Cancel then the installer finishes its work and closes. The problem is that I don't know how to show that custom window before all the wizard pages and if it's even possible to do that?

Also, I use ISSI to show the splash screen:

#define ISSI_Splash "C:\InnoSetupProject\Images\client.bmp"                    
#define ISSI_Splash_T 3                                                                      
#define ISSI_Splash_X 500                                                                     
#define ISSI_Splash_Y 220                                                                                                                                     

There's also one problem with that. If I show the MsgBox dialog before the first wizard page and press Cancel on it I want my setup program to close, but instead it shows me the splash screen anyway and then closes. Can I somehow cancel it if I need it in InitializeSetup?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
JConstantine
  • 1,020
  • 7
  • 19

2 Answers2

0

According to the CreateCustomPage documentation the parameters for creating a custom page are as follows:

function CreateCustomPage(const AfterID: Integer;
                          const ACaption,
                          ADescription: String): TWizardPage;

As you can see, you are providing AfterID which implies you can tell it to show a custom page after a specific builtin page.

But, have you considered using PrepareToInstall? It says:

You can use this event function to detect and install missing prerequisites and/or to shutdown any application which is about to be updated.

So maybe you can do your tests there and show any needed pop-up message box. Then, based on the reply, you can return with the appropriate error message. The documentation explains.

There might be other ways to do what you want.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • _AfterID which implies you can tell it to show a custom page before a specific builtin page._ - how does **AfterID** imply that I **can** show the custom page **before** the built-in one? – JConstantine Mar 31 '20 at 19:54
  • Sorry, I am tired. I meant **after**. – Andrew Truckle Mar 31 '20 at 19:56
  • I don't think I can use the `PrepareToInstall` function, because I need to do all the checks before the first wizard page shows up. – JConstantine Mar 31 '20 at 20:09
0

Use the code from:
Is it possible to check if program is already running before trying to install it? (Inno Setup)
(it's your question!)

And just replace IsAppRunning with your IsClientLaunched.

Though, now the question is, whether you need your custom IsClientLaunched at all. You can use the IsAppRunning instead.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • The main thing here is how can I show my custom window **before** all other wizard pages. – JConstantine Mar 31 '20 at 19:50
  • That's exactly what the code does! Did you try it? `InitializeSetup` event is triggered *before the installation wizard even shows*. – Martin Prikryl Mar 31 '20 at 19:58
  • Yes, I did try it, but it won't be the custom page then. It's going to be the message box where I can choose only from the standard set of buttons and cannot put an image for example, what I also need to do. – JConstantine Mar 31 '20 at 20:05
  • Also, the language selection page and the splash screen still go before the `InitializeSetup` function is called. – JConstantine Mar 31 '20 at 20:12
  • You can't put anything before the language page I don't think. – Andrew Truckle Mar 31 '20 at 20:12
  • You wrote *"custom window"*, not *"custom page"*. – So make it clear what you want! – And yes, you cannot put anything before the language dialog. And your question does not mention any splash screen. And if you want a custom *page* of the wizard window, then it *obviously* have to go *after* the language selection and the slash screen. How else would it work? – Martin Prikryl Mar 31 '20 at 20:31
  • 1
    To display anything before the language dialog, you would have to use a hack list this: [Inno Setup - Language selector with VCL Styles](https://stackoverflow.com/q/41021292/850848). – But still, it cannot be a wizard *page*, it has to be custom window/dialog. – Martin Prikryl Mar 31 '20 at 20:44
  • @MartinPrikryl The other problem with that `IsAppRunning` method is that `MsgBox` buttons are not translated, but stick to the language of my Windows. I need them translated though. – JConstantine Apr 01 '20 at 01:31
  • 1
    Well, first note that that's true for all Inno Setup message boxes (for example the message boxes for `AppMutex` or the box for confirming cancel all have the buttons in your Windows language). And [creating a custom dialog](https://stackoverflow.com/q/25515610/850848), where you can localize the buttons is not a problem. Actually the [question I have posted above](https://stackoverflow.com/q/41021292/850848) does exactly that. – Martin Prikryl Apr 01 '20 at 05:56
  • And how can you even want to localize the buttons, if you want to show the page before the languages dialog? So what are you current requirements? Your question still says nothing about the languages dialog and the splash screen. – Martin Prikryl Apr 01 '20 at 06:14
  • @MartinPrikryl Well, I have to agree on the fact that showing the localized buttons before the language selection screen is not the best idea. I've edited my question and added there some info about the splash screen. – JConstantine Apr 02 '20 at 00:28
  • You didn't show us how particularly you have solved the problem with duplicate `InitializeSetup` event function. I do not get the splash screen. – Martin Prikryl Apr 02 '20 at 06:37