The INF script language has built-in commands, dialog templates, and shell scripts that provide a mechanism for displaying simple message box dialogs. To display custom dialogs, create a DLL that displays the dialog and returns the user’s input.
The subroutn.inf file located in the Windows NT System32 directory contains a SetupMessage shell section that displays a message box dialog. Call SetupMessage from a driver’s oemsetup.inf file using the following syntax:
shell “subroutn.inf” SetupMessage LangID Template Message
SetupMessage returns two values. The first return value indicates success or failure. It returns STATUS_SUCCESSFUL, STATUS_FAILURE, or STATUS_NOLANGUAGE if the LangID argument specifies an unsupported language. If the first return value is STATUS_SUCCESSFUL, the second return value indicates the button pressed (either OK or CANCEL).
For example, these lines from an INF script display the dialog shown below, and handle the return values:
shell "subroutn.inf" SetupMessage $(!STF_LANGUAGE) WARNING+ "Looks like trouble. Do you want to continue?" ifstr(i) $($R0) != STATUS_SUCCESSFUL goto HandleError endif ifstr(i) $($R1) == "OK" goto ContinueOperation else-ifstr(i) $($R1) == "CANCEL" goto BailOut endif
For additional customization of the message box dialog, you can use the ui start command as shown in the following example. Note that the string specified after ui start is required, but has no significance.
read-syms CustomMessageDlg ; setup the message box variables ui start "CustomMessageBox" ifstr(i) $(DLGEVENT) == "ABORT" ; DLGEVENT indicates button pressed goto AbortProcedure else-ifstr(i) $(DLGEVENT) == "RETRY" goto RetryProcedure else-ifstr(i) $(DLGEVENT) == "IGNORE" goto IgnoreProcedure else exit endif [CustomMessageDlg] DlgType = "MessageBox" STF_MB_TITLE = "Message Box Dialog" STF_MB_TEXT = "Message Text" STF_MB_TYPE = 6 ; display Abort, Retry, and Ignore buttons STF_MB_ICON = 5 ; ! icon STF_MB_DEF = 2 ; default button is Retry
For the MessageBox dialog, the STF_MB_TITLE variable is optional, but all other variables in the following table must be set. Determine the button pressed by examining the DLGEVENT variable, which is set to one of the following strings: “ABORT”, “CANCEL”, “IGNORE”, “NO”, “OK”, “RETRY”, or “YES”.
DlgType = MessageBox
1 OK button
2 OK and Cancel buttons
3 Yes and No buttons
4 Yes, No, and Cancel buttons
5 Retry and Cancel buttons
6 Abort, Retry, and Ignore buttons
1 No icon
2 Info icon
3 Stop icon
4 ? icon
5 ! icon