初始化驱动程序

初始化函数 WpdBaseDriver::InitializeWpdBaseDriver::Uninitialize 在 WpdHelloWorldDriver 示例中为空。 Initialize 函数只返回S_OK,而 Uninitialize 函数不执行任何操作。

示例驱动程序的以下摘录包含 WpdBaseDriver::InitializeWpdBaseDriver::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()
{
}

如果要移植此示例以支持实际设备(例如,蓝牙手机)时,将在 Initialize 函数中添加功能以初始化驱动程序的 I/O 库。 发出设备命令。 对于移动电话,此库可能包含用于枚举电话簿或设置或检索手机存储中的文件的命令。 Initialize 函数 至少 会建立设备的网络地址。 WPDBaseDriver::Uninitialize 函数将执行任何所需的清理。