ILocationEvents::OnStatusChanged 方法 (locationapi.h)

[Win32 位置 API 可用于“要求”部分中指定的操作系统。 它可能在后续版本中变更或不可用。 请改用 Windows.Devices.Geolocation API。 ]

在报表状态更改时调用。

语法

HRESULT OnStatusChanged(
  [in] REFIID                 reportType,
  [in] LOCATION_REPORT_STATUS newStatus
);

parameters

[in] reportType

REFIID ,指定其状态已更改的报表类型的接口 ID。

[in] newStatus

包含新状态的 LOCATION_REPORT_STATUS 枚举中的常量。

返回值

如果该方法成功,则返回 S_OK。 否则,将返回 HRESULT 错误代码。

注解

此事件提供新报表的报表状态。 无论此事件报告的状态如何,最新的报告仍可通过 ILocation::GetReport 获得。

示例

下面是 OnStatusChanged 的示例实现,用于处理纬度/经度报表的状态更改事件。

// This is called when the status of a report type changes.
// The LOCATION_REPORT_STATUS enumeration is defined in LocApi.h in the SDK
STDMETHODIMP CLocationEvents::OnStatusChanged(REFIID reportType, LOCATION_REPORT_STATUS status)
{
    if (IID_ILatLongReport == reportType)
    {
        switch (status)
        {
        case REPORT_NOT_SUPPORTED:
            wprintf(L"\nNo devices detected.\n");
            break;
        case REPORT_ERROR:
            wprintf(L"\nReport error.\n");
            break;
        case REPORT_ACCESS_DENIED:
            wprintf(L"\nAccess denied to reports.\n");
            break;
        case REPORT_INITIALIZING:
            wprintf(L"\nReport is initializing.\n");
            break;
        case REPORT_RUNNING:
            wprintf(L"\nRunning.\n");
            break;
        }
    }
    else if (IID_ICivicAddressReport == reportType)
    {
    }

    return S_OK;
}

要求

   
最低受支持的客户端 Windows 7 [仅限桌面应用],Windows 7
最低受支持的服务器 无受支持的版本
目标平台 Windows
标头 locationapi.h
DLL LocationAPI.dll

另请参阅

ILocationEvents