Inicialización del controlador

Las funciones de inicialización, WpdBaseDriver::Initialize y WpdBaseDriver::Uninitialize están vacías en el ejemplo wpdHelloWorldDriver. La función Initialize simplemente devuelve S_OK y la función Uninitialize no hace nada.

El siguiente fragmento del controlador de ejemplo contiene el código de WpdBaseDriver::Initialize y WpdBaseDriver::Uninitialize.

/**
 * This method is called to initialize the driver object.
 * This is where the driver would set up its I/O libraries
 * and so on.
 */
HRESULT WpdBaseDriver::Initialize()
{

    return S_OK;
}

/**
 * This method is called to uninitialize the driver object.
 * In a real driver, this is where the driver would clean up
 * any resources held by this driver.
 */
VOID WpdBaseDriver::Uninitialize()
{
}

Si quisiera portar este ejemplo para admitir un dispositivo real (por ejemplo, un teléfono móvil habilitado para Bluetooth), debería añadir funcionalidad a la función Inicializar para inicializar la biblioteca de E/S del controlador. que emite los comandos del dispositivo. En el caso del teléfono móvil, esta biblioteca puede incluir comandos para enumerar una libreta de teléfonos, o para establecer o recuperar archivos en el almacenamiento del teléfono. Como mínimo, la función Initialize establecería la dirección de red del dispositivo. La función WPDBaseDriver::Uninitialize realizaría cualquier limpieza necesaria.