Sample Function 2: DI_Term

This application-defined sample function deallocates existing DirectInput interface pointers in preparation for program shutdown or in the event of a failure to properly initialize a device.

//  LPDIRECTINPUT        g_lpDI; 
//  LPDIRECTINPUTDEVICE  g_lpDIDevice; 
 
void WINAPI DI_Term() 
{ 
    if (g_lpDI) 
    { 
        if (g_lpDIDevice) 
        { 
            /* 
             */ 
             g_lpDIDevice->Unacquire(); 
             g_lpDIDevice->Release();
             g_lpDIDevice = NULL; 
        } 
        g_lpDI->Release();
        g_lpDI = NULL; 
    } 
}