首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Inno安装程序中基于国家的下载

Inno安装程序中基于国家的下载
EN

Stack Overflow用户
提问于 2016-03-24 06:52:17
回答 1查看 302关注 0票数 1

我正在尝试使用Inno设置我的软件。目前,我的软件每天从不同的Geo上下载超过6000次。问题是我的软件对每个geo执行的不同,所以我为每个geo创建了不同的exe。目前正在使用Inno设置作为我的软件的下载管理器。现在,如何找到用户是从哪个geo,以及我如何告诉我的Inno安装脚本下载的exe,哪里的用户是从。

目前我所拥有的是:

代码语言:javascript
复制
#define MyAppName ""
#define MyAppVersion "1"
#define _URL ""
#define _exeFileName "setup.exe"
#include ReadReg(HKEY_LOCAL_MACHINE,'Software\Sherlock Software\InnoTools\Downloader','ScriptPath','');
[Setup]
AppId={{7B0D8E4E-BAFD-400B-B775-0DD7D8FBAE08}
AppName={#MyAppName}
AppVersion={#MyAppVersion};
AppVerName={#MyAppName} {#MyAppVersion}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
DisableFinishedPage=yes
OutputBaseFilename={#MyAppName}{#MyAppVersion}
Compression=lzma
SolidCompression=yes
DisableWelcomePage=yes
DisableReadyPage=yes
DisableReadyMemo=True
Uninstallable=no
RestartIfNeededByRun=no                     
CreateAppDir=False
UsePreviousGroup=False

如果有人能帮我解决这个问题,那就太好了。

提前感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-24 08:21:54

我不知道什么是解决这个位置的最好方法。这是另一个问题。

但你可以使用一些在线服务。

例如,https://ipinfo.io/country

它返回一个两位数的ICO国家代码。

您可以使用WinHttpRequest读取代码。请参阅How to read a text file from the Internet resource?

下面的示例演示如何将其与Inno下载插件相结合:

代码语言:javascript
复制
var
  Country: string;

function GetCountry: string;
var
  WinHttpReq: Variant;
begin
  if Country <> '' then
  begin
    Log(Format('Using cached country: %s', [Country]));
    Result := Country;
  end
    else
  begin
    try
      WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
      WinHttpReq.Open('GET', 'https://ipinfo.io/country', False);
      WinHttpReq.Send;
      Result := Trim(WinHttpReq.ResponseText);
    except
      Log(GetExceptionMessage);
      Result := 'XX';
    end;

    Country := Result;
    Log(Format('Resolved country: %s', [Country]));
  end;
end;

function InitializeSetup(): Boolean;
begin
  idpAddFile(
    'https://example.com/file-for-' + GetCountry + '.exe',
    ExpandConstant('{tmp}\file.exe'));
end;

顺便说一句,你有没有考虑在下载的时候解决你网站上的地理位置问题?让用户直接下载特定于他/她位置的安装程序?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36194647

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档