Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Geolocation or how to find the country were my app is started

Geolocation or how to find the country were my app is started

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++comjsontutorial
8 Posts 2 Posters 11 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jung kreidler
    wrote on last edited by
    #1

    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?

    V J 2 Replies Last reply
    0
    • J jung kreidler

      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?

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      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?

      J 1 Reply Last reply
      0
      • V Victor Nijegorodov

        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?

        J Offline
        J Offline
        jung kreidler
        wrote on last edited by
        #3

        spLocation->GetReportStatus(IID_ILatLongReport, &status) returns REPORT_NOT_SUPPORTED. The code is from one of the Microsoft samples.

        V 1 Reply Last reply
        0
        • J jung kreidler

          spLocation->GetReportStatus(IID_ILatLongReport, &status) returns REPORT_NOT_SUPPORTED. The code is from one of the Microsoft samples.

          V Offline
          V Offline
          Victor Nijegorodov
          wrote on last edited by
          #4

          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?

          J 1 Reply Last reply
          0
          • V Victor Nijegorodov

            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?

            J Offline
            J Offline
            jung kreidler
            wrote on last edited by
            #5

            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.

            V 1 Reply Last reply
            0
            • J jung kreidler

              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.

              V Offline
              V Offline
              Victor Nijegorodov
              wrote on last edited by
              #6

              Then you need some device or some tool giving you current PC geo-coordinates....

              1 Reply Last reply
              0
              • J jung kreidler

                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?

                J Offline
                J Offline
                jung kreidler
                wrote on last edited by
                #7

                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);
                }

                V 1 Reply Last reply
                0
                • J jung kreidler

                  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);
                  }

                  V Offline
                  V Offline
                  Victor Nijegorodov
                  wrote on last edited by
                  #8

                  :thumbsup: G:thumbsup:lad you have solved your problem! :)

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups