//#include "stdafx.h"
#include <windows.h>
#include <atlbase.h>
#include <atlcom.h>
#include <LocationApi.h>
#include <conio.h>
int main(int argc,char *argv[])
{
// The location object.
CComPtr<ILocation> spLocation;
// Array of report types to request permissions for.
IID REPORT_TYPES[] = { IID_ILatLongReport };
// Create the Location object.
if (SUCCEEDED(spLocation.CoCreateInstance(CLSID_Location)))
{
// Request permissions for this user account to receive location data for the
// types defined in REPORT_TYPES (which contains one report type in this example).
// TRUE, in the last parameter, specifies a synchronous request
HRESULT hr = spLocation->RequestPermissions(NULL,REPORT_TYPES,ARRAYSIZE(REPORT_TYPES),TRUE);
}
}
Efekt:
1>------ Build started: Project: test, Configuration: Debug Win32 ------
1>Build started 2010-05-03 1356.
1>InitializeBuildStatus:
1> Touching "Debug\test.unsuccessfulbuild".
1>ClCompile:
1> main.cpp
1>main.obj : error LNK2001: unresolved external symbol _CLSID_Location
1>main.obj : error LNK2001: unresolved external symbol _IID_ILatLongReport
1>E:\projects\test\test\Debug\test.exe : fatal error LNK1120: 2 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 0001.63
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Kompilator: Visual Studio 2010 Ultimate
Projekt: General->Empty Project
Co jest źle? Skopiowałem to ze strony MS, więc teoretycznie powinno działać: include + reszta
Co ciekawe, nawet Google nic na ten temat nie wie: http://www.google.pl/#hl=pl&source=hp&q=unresolved+external+symbol+_CLSID_Location&lr=&aq=f&aqi=&aql=&oq=&gs_rfai=&fp=65965e2e80e38542