(locationapi.h) LOCATION_REPORT_STATUS 枚举

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

定义特定报表类型的新报表的可能状态。

语法

typedef enum LOCATION_REPORT_STATUS {
  REPORT_NOT_SUPPORTED = 0,
  REPORT_ERROR = 1,
  REPORT_ACCESS_DENIED = 2,
  REPORT_INITIALIZING = 3,
  REPORT_RUNNING = 4
} ;

常量

 
REPORT_NOT_SUPPORTED
值: 0
API 不支持请求的报表类型。 未安装所请求类型的位置提供程序。
REPORT_ERROR
值:1
创建报表时出错,或者请求的类型的位置提供程序无法提供任何数据。 位置提供程序当前可能不可用,或者位置提供程序无法获取任何数据。 例如,当 GPS 传感器在室内且没有卫星在视野中时,可能会出现此状态。
REPORT_ACCESS_DENIED
值: 2
尚未授予访问此报表类型的权限。 调用 ILocation::RequestPermissions
REPORT_INITIALIZING
值: 3
正在初始化报表。
REPORT_RUNNING
值: 4
报表正在运行。 请求的报表类型的新位置数据可用。

注解

这些值表示新报表的状态。 无论报告的状态如何,最新的报表仍可通过 ILocation::GetReport 获得。 如果状态为 REPORT_RUNNING,则报表中的数据为新数据。 否则,如果缓存数据可用, ILocation::GetReport 将提供缓存数据。

示例

下面的代码示例演示如何从 ILocation::GetReportStatus 检索LOCATION_REPORT_STATUS值。

    // Get the status of this report type
    if (SUCCEEDED(spLocation->GetReportStatus(IID_ILatLongReport, &status))) 
    {
        bool fIsNotRunning = true;
        switch (status) 
        {
        case REPORT_RUNNING:
            // If the status for the current report is running,
            // then do not print any additional message.
            // Otherwise, print a message indicating that reports may contain cached data.
            fIsNotRunning = false;
            break;
        case REPORT_NOT_SUPPORTED:
            wprintf(L"\nThere is no sensor installed for this report type.\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;
        }

        if (true == fIsNotRunning)
        {
            wprintf(L"Location reports returned from GetReport contain cached data.\n");
        }
    }

以下代码是回调函数 ILocationEvents::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
最低受支持的服务器 无受支持的版本
标头 locationapi.h