UDI validators are DLLs written in C++ that implement the IValidator interface. You register the DLL with the UDI Wizard Designer validator library by creating a UDI Wizard Designer configuration file (.config file) and placing it in the installation_folder\Bin\Config folder (where installation_folder is the folder in which you installed MDT).

To create custom UDI validators

1.   Write code that creates a subclass of the BaseValidator class and implements the following methods:

·     Init(IControl *pControl, IWizardPageContainer *pContainer, IStringProperties *pProperties). The form controller calls the Init member to initialize the validator. This method must call the Init method for the BaseValidator class. It typically reads any properties set for the validator from the UDI Wizard configuration file. For example, the InvalidCharactersValidator validator retrieves the value of the InvalidChars property using this method.

·     IsValid. The form controller calls this method to see whether the control contains valid text. The following is an example of the IsValid method for a validator that validates that the field is not empty:

BOOL IsValid(LPBSTR pMessage)

{

    __super::IsValid(pMessage);

 

    _bstr_t text;

    m_pText->GetText(text.GetAddress());

    return (text.length() > 0);

}

·     Init(IControl *pControl, LPCTSTR message). The form controller calls this member for each keystroke and other events so that the validator can validate the contents of the control and updated messages at the bottom of the wizard page (or clear them).

Typically, these are the only methods that you need to override. However, depending on the validator, you may need to override other methods in the subclass of the BaseValidator class you create. For more information about these other methods, see the BaseValidator class.

2.   Write code that registers the custom task class with the registry factory.

3.   Build the solution for your custom task.

Note   Ensure that the version of the DLL you create is the same processor platform as the installation of MDT. For example, if you install the 64-bit version of MDT, then build a 64-bit version of your custom UDI task.

4.   Create a Validator element under the ValidatorLibrary element in the UDI Wizard Designer configuration file similar to the following excerpt:

<Validator

<Validator DLL="" Description="Must follow a pre-defined pattern" Type="Microsoft.Wizard.Validation.RegEx" Name="NamedPattern">

   <Param Description="Enter the message you want displayed when the text in this field doesn't match the pattern:" Name="Message" DisplayName="Message"/>

   <Param Description="The name of a pre-defined regular expression pattern. Must be Username, ComputerName, or Workgroup" Name="NamedPattern" DisplayName="Named Pattern"/>

</Validator>

Note   All Validator elements should include the Message parameter. Specify all other parameters as required by the validator. For example, in the previous excerpt, the NamedPattern parameter is used to specify a parameter for the name of a predefined regular expression pattern.

5.   Copy the UDI Wizard Designer configuration file created in the previous step to the installation_folder\Bin\Config folder (where installation_folder is the folder in which you installed MDT).

6.   Copy the DLL for your custom task to the installation_folder\Templates\Distribution\Tools\ platform folder (where installation_folder is the folder in which you installed MDT and platform is x86 for the 32-bit version or x64 is for the 64-bit version).


Related Topics

User-Driven Installation Developers Guide