ILocation::RequestPermissions method (locationapi.h)
[The Win32 Location API is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. Instead, use the Windows.Devices.Geolocation API. ]
Opens a system dialog box to request user permission to enable location devices.
Syntax
HRESULT RequestPermissions(
[in] HWND hParent,
[in] IID *pReportTypes,
[in] ULONG count,
BOOL fModal
);
Parameters
[in] hParent
HWND for the parent window. This parameter is optional. In Windows 8 the dialog is always modal if hParent is provided, and not modal if hParent is NULL.
[in] pReportTypes
Pointer to an IID array. This array must contain interface IDs for all report types for which you are requesting permission. The interface IDs of the valid report types are IID_ILatLongReport and IID_ICivicAddressReport. The count of IDs must match the value specified through the count parameter.
[in] count
The count of interface IDs contained in pReportTypes.
fModal
This parameter is not used.
Return value
This method can return one of these values.
The following table describes return codes when the call is synchronous.
Return code | Description |
---|---|
|
The user enabled location services. The method succeeded. |
|
The location platform is disabled. An administrator turned the location platform off. |
|
The user did not enable access to location services or canceled the dialog box. |
The following table describes return codes when the call is asynchronous.
Return code | Description |
---|---|
|
The user enabled access to location services. The method succeeded. |
|
An argument is not valid. |
|
The location platform is disabled. An administrator turned the location platform off. The dialog box was not shown. |
Remarks
If the user chooses not to enable location services, Windows will not show the permissions dialog box again.
Examples
The following example demonstrates how to call RequestPermissions to request permission for latitude/longitude reports.
// Array of report types of interest. Other ones include IID_ICivicAddressReport
IID REPORT_TYPES[] = { IID_ILatLongReport };
// Request permissions for this user account to receive location data for all the
// types defined in REPORT_TYPES (which is currently just one report type)
// The last parameter is not used.
if (FAILED(spLocation->RequestPermissions(
NULL,
REPORT_TYPES,
ARRAYSIZE(REPORT_TYPES),
TRUE)))
{
wprintf(L"Warning: Unable to request permissions.\n");
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 7 [desktop apps only],Windows 7 |
Minimum supported server | None supported |
Target Platform | Windows |
Header | locationapi.h |
DLL | LocationAPI.dll |