An Example Callback Function

A simple setup program could contain a callback function along the lines of the following:

DWORD MySetupCallback(
    DWORD Reason, 
    DWORD MsgType, 
    char *szMessage, 
    char *szName, 
    DSETUP_CB_UPGRADEINFO *pUpgradeInfo)
{
    if (MsgType==0)        // ignore status messages
        return ID_OK;

    return MessageBox(MyhWnd, szMessage, 
                     "My Application Name", MsgType);
}
 

This example ignores all status messages, but displays error messages by calling the MessageBox function.

The address of the callback function in the previous example would be passed to DirectSetup prior to calling the DirectXSetup function. The following code gives an example of how this is done.

// Set the callback function.
DirectXSetupSetCallback(MySetupCallback);
// Start the setup of DirectX components and drivers.
if (SUCCESS(DirectXSetup(hWndParent, NULL,
                         DSETUP_DIRECTX))
    {
        // The installation succeeded.
    }
    else
    {
        /* Installation failed. Handle the error in MySetupCallback.
        Do any additional cleanup needed right here. */
    }