Archive: Access to Destination Folder string


Access to Destination Folder string
I am implementing an installation script with the Modern UI. NSIS carries out checks on the string in the Destination Folder before exiting the Directory Page. As part of those checks any invalid characters ( *?|<>/": ) are deleted. This means that the actual install directory may not be the same as the one shown in the Destination Folder edit box.

I am not happy with this behaviour and want to stop the install with an appropriate message if the string in the Destination Folder contains any invalid characters. My preferred approach is to let the user set the string and then check it when the install button is pressed.

I have tried implementing this by checking the $INSTDIR variable using a MUI_PAGE_CUSTOMFUNCTION_LEAVE. However, the $INSTDIR variable has already had the invalid characters stripped at this point.

Is there any way to access the string in the Destination Folder directly for these checks? Or is there a better way to implement what I'm trying to do?

Any help would be much appreciated,
Bob


You could change the NSIS source, or you could try this:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.8.1.16
Then in the Page's Leave function, use one of these functions:
http://nsis.sourceforge.net/archive/...ances=0,11,122

Hope that helps!

-Stu


Afrow UK, Thanks for your reply.

I had already tried using GetInstDirError with MUI_DIRECTORYPAGE_VERIFYONLEAVE, but it seems to only check after the invalid characters have been removed because GetInstDirError returns 0 (valid).

Wish I'd seen your second link earlier, it would have saved me inventing my own (less efficient) version of searching for invalid characters in a string.

Bob


I found a solution; to use a different variable other than $INSTDIR by using DirVar...

Var $MYINSTDIR
PageEx Directory
PageCallbacks "" "" DirLeave
DirVerify leave
DirVar $MYINSTDIR
PageExEnd
-Stu

That's great Stu!

In fact I've managed to implemented it sticking to the MUI items as follows:

Var MyInstallDir
!define MUI_DIRECTORYPAGE_VARIABLE $MyInstallDir
!define MUI_PAGE_CUSTOMFUNCTION_PRE DirPre
!define MUI_PAGE_CUSTOMFUNCTION_PRE DirLeave
..
Function DirPre
StrCpy $MyInstallDir $INSTDIR
FunctionEnd

plus a bunch of directory checking code in DirLeave

Many thanks Stu
Does this forum have a system of reward points for useful posts. You'd get my vote, especially as you're almost a neighbour!


Don't worry 'bout it :)

-Stu