Geolocation or how to find the country were my app is started
-
My app is C++ based (no .net) and I need to know where on earth my app is started. This is in order to access a website (e.g. www.xyz.cn/info for china; www.xyz.com/info for the rest) with the correct region. I've tried with ILocation Com interface but it tells me that there are 'no devices detected'. Any thaughts?
-
My app is C++ based (no .net) and I need to know where on earth my app is started. This is in order to access a website (e.g. www.xyz.cn/info for china; www.xyz.com/info for the rest) with the correct region. I've tried with ILocation Com interface but it tells me that there are 'no devices detected'. Any thaughts?
jung-kreidler wrote:
've tried with ILocation Com interface but it tells me that there are 'no devices detected'.
What method of ILocation gives you this error?
-
jung-kreidler wrote:
've tried with ILocation Com interface but it tells me that there are 'no devices detected'.
What method of ILocation gives you this error?
spLocation->GetReportStatus(IID_ILatLongReport, &status) returns REPORT_NOT_SUPPORTED. The code is from one of the Microsoft samples.
-
spLocation->GetReportStatus(IID_ILatLongReport, &status) returns REPORT_NOT_SUPPORTED. The code is from one of the Microsoft samples.
Well, from MSDN:
Quote:
REPORT_NOT_SUPPORTED The requested report type is not supported by the API. No location providers of the requested type are installed.
Does the PC have any means to locate GPS posituion?
-
Well, from MSDN:
Quote:
REPORT_NOT_SUPPORTED The requested report type is not supported by the API. No location providers of the requested type are installed.
Does the PC have any means to locate GPS posituion?
No, this is a normal PC without GPS. I just need the country where my app was started in order to access the right webaddress provided for the country.
-
No, this is a normal PC without GPS. I just need the country where my app was started in order to access the right webaddress provided for the country.
Then you need some device or some tool giving you current PC geo-coordinates....
-
My app is C++ based (no .net) and I need to know where on earth my app is started. This is in order to access a website (e.g. www.xyz.cn/info for china; www.xyz.com/info for the rest) with the correct region. I've tried with ILocation Com interface but it tells me that there are 'no devices detected'. Any thaughts?
As I do only need the country where my app was started the following code does the job:
std::string get_country_code()
{HINTERNET net = InternetOpen("IP retriever",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,
NULL,
0);HINTERNET conn = InternetOpenUrl(net,
"http://ip-api.com/csv/?fields=countryCode",
NULL,
0,
INTERNET_FLAG_RELOAD,
0);char buffer[12096];
DWORD read;InternetReadFile(conn, buffer, sizeof(buffer) / sizeof(buffer[0]), &read);
InternetCloseHandle(net);return std::string(buffer, read);
} -
As I do only need the country where my app was started the following code does the job:
std::string get_country_code()
{HINTERNET net = InternetOpen("IP retriever",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,
NULL,
0);HINTERNET conn = InternetOpenUrl(net,
"http://ip-api.com/csv/?fields=countryCode",
NULL,
0,
INTERNET_FLAG_RELOAD,
0);char buffer[12096];
DWORD read;InternetReadFile(conn, buffer, sizeof(buffer) / sizeof(buffer[0]), &read);
InternetCloseHandle(net);return std::string(buffer, read);
}:thumbsup: G:thumbsup:lad you have solved your problem! :)