Archive: MessageBox in the function


MessageBox in the function
I read the Installation directory from the registry; in a custom page I would check if this installation directory exists or not (is empty): I have used the code

Page custom ShowInfo LeaveInfo
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE VerifyDirectory
!insertmacro mui_page_directory
...
Function VerifyDirectory
StrCmp $INSTDIR "" +1 +2
MessageBox MB_OK|MB_ICONSTOP $(ProgramNotFound) ; if program not found message
FunctionEnd

but it does not work not showing the message in both cases. I have used the StrCmp and MessageBox instructions in the LeaveInfo function and there the message is always (in both cases) shown. How to fix it ?


Instead of 'StrCmp $INSTDIR "" +1 +2' try:

IfFileExists "$INSTDIR\*.*" +2 +1

The asterisks are wildcards. It basicly checks to see if there are any files in the directory (same as checking if the directory exists).


I have tried it, so it is right.

I have noted if I use 'iffileexists "$instdir\." +2 +1' it works too.

Massimo