ILocation::GetReport 方法 (locationapi.h)

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

检索位置报告。

语法

HRESULT GetReport(
  [in]  REFIID          reportType,
  [out] ILocationReport **ppLocationReport
);

参数

[in] reportType

REFIID ,指定要检索的报表类型。

[out] ppLocationReport

指向接收指定位置报告的 ILocationReport 的指针的地址。

返回值

该方法返回 HRESULT。 可能的值包括(但并不限于)下表中的项。

返回代码 说明
S_OK
方法成功。
E_ACCESSDENIED
位置提供程序已禁用权限,并且无法检索报表数据。
HRESULT_FROM_WIN32 (ERROR_NOT_SUPPORTED)
reportType 不是 IID_ILatLongReportIID_ICivicAddressReport
HRESULT_FROM_WIN32 (ERROR_NO_DATA)
没有可用的数据。 这可能是由于错误或提供程序不可用造成的。
E_POINTER
ppLocationReportNULL
E_INVALIDARG
reportType 为IID_ILatLongReport,纬度或经度值超出边界。
E_FAIL
基础传感器为 NULL 或断开连接。
E_OUTOFMEMORY
内存不足。

注解

ILocationReport 是特定位置报表类型的基接口。 调用 QueryInterface 以检索指向正确报表类型的指针。

调用 GetReport 时,如果这是应用程序首次使用位置,则可能导致在任务栏中显示通知,并记录位置活动事件事件查看器。

注意 当应用程序首次启动时,或者启用新位置传感器时, GetReportStatus 可能会在新位置报告可用前不久报告 REPORT_RUNNING 状态。 因此,初始调用 GetReport 可能会返回错误 (ERROR_NO_DATA) 或不是来自预期位置传感器的值,即使 GetReportStatus 指示 REPORT_RUNNING状态也是如此。 有关此问题的解决方法的说明,请参阅 GetReportStatus
 

示例

以下示例为纬度/经度报表调用 GetReport ,并演示如何调用 QueryInterface 来检索指向指定报表类型的指针。

CComPtr<ILocationReport> spLocationReport; // This is our location report object
CComPtr<ILatLongReport> spLatLongReport; // This is our LatLong report object

// Get the current latitude/longitude location report,
hr = spLocation->GetReport(IID_ILatLongReport, &spLocationReport);
// then get a pointer to the ILatLongReport interface by calling QueryInterface
if (SUCCEEDED(hr))
{
    hr = spLocationReport->QueryInterface(&spLatLongReport);
}

要求

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