创建设备查找器

以下示例演示如何使用 C++、Visual Basic 和 VBScript 创建 Device Finder 对象的实例。 脚本语言使用编程 ID (ProgID) UPnP.UPnPDeviceFinder 来标识设备查找器类。 C++ 代码使用类标识符。

C++ 示例

HRESULT hr = S_OK;
IUPnPDeviceFinder *pDeviceFinder = NULL;

hr = CoCreateInstance(CLSID_UPnPDeviceFinder, 
                      NULL,
                      CLSCTX_INPROC_SERVER,
                      IID_IUPnPDeviceFinder,
                      (void **) &pDeviceFinder);

如此 C++ 示例所示,Device Finder 对象公开默认接口 IUPnPDeviceFinder。 此接口的方法根据基于 UPnP 的设备的有效搜索条件执行搜索。 此接口支持自动化,因此可通过编写脚本代码调用其方法。

VBScript 示例

Dim deviceFinder

Set deviceFinder = CreateObject( "UPnP.UPnPDeviceFinder" )