[wix-users] How to ensure the PathEdit control value is non empty

shashank khadse shashank.s.khadse at gmail.com
Thu Sep 14 07:38:29 PDT 2017


Hello ,
I have customized wix UI for installer.
The PathEdit control is being used for the installation directory selection.
The control is linked with the *WIXUI_INSTALLDIR *property as specified in
following code snippet ...

<Control Id="FolderLabel"   Type="Text"         X="20"  Y="52"  Width="375"
 Height="18" NoPrefix="yes" Text="Installation Directory" />
<Control Id="Folder"           Type="*PathEdit*"   X="20"  Y="70"
 Width="290"  Height="18" Property="*WIXUI_INSTALLDIR*" Indirect="yes"
Text="{200}"/>


The property *WIXUI_INSTALLDIR is *defined in Product.wxs

<Property Id="WIXUI_INSTALLDIR"   Value="*MYINSTALLDIR*" Secure="yes" />


whereas the "MYINSTALLDIR" is used in Fragment like this

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
       <Directory Id="ProgramFiles64Folder">
     <Directory Id="INSTALLFOLDER" Name="MyFolder">
             <Directory Id="*MYINSTALLDIR*" Name="MyInstallDir">
</Directory>
                            </Directory>
   </Directory>
   </Directory>
</Fragment>


According to the above changes, the default installation directory is
assigned properly as defined above.
Also the immediate custom action for path validation gets the appropriate
value.

But as soon as the user provides blank ( I mean empty ) installation path
in the pathEdit control,
the path validation custom action still receives the default value (
"*C:\Program
Files\MyFolder\MyInstallDi*r" )  for the property *WIXUI_INSTALLDIR .*
It is expected to receive empty value instead of default path. However the
UI still shows the empty path (as expected ).

If any other directory path  is mentioned then the property gets updated
properly and in the custom action updated value is available.

How do I ensure that the PathEdit control does not allow the user to enter
non-empty value only ?
or In case if there is no option, how to ensure that the property
*WIXUI_INSTALLDIR
*is passed on to the immediate custom action as empty,
so that I can perform empty check in the code to display an error msg to
the user ?

Here is the part of custom action

UINT __stdcall ValidateInstallDirPath(MSIHANDLE hInstall)
{
    HRESULT hr = S_OK;

    LPWSTR pwszWixUIDir = NULL;
    LPWSTR pwszInstallPath = NULL;

    hr = WcaInitialize(hInstall, "ValidateInstallDirPath");
    ExitOnFailure(hr, "failed to initialize");

    hr = WcaGetProperty(L"*WIXUI_INSTALLDIR*", &pwszWixUIDir);    //////
 pwszWixUIDir --> *MYINSTALLDIR*
    ExitOnFailure(hr, "failed to get WixUI Installation Directory");

    hr = WcaGetProperty(pwszWixUIDir, &pwszInstallPath);
    ExitOnFailure(hr, "failed to get Installation Directory");

    .
    . // some code goes here
    .

}


Kindly help me to resolve this issue.

Thanks in advance
Shashank


More information about the wix-users mailing list