我正在为 Microsoft Office 创建一个安装程序,特别是 2007 - 2013 版本。它只是复制两个 Office 目录中的一些文件。我的 Windows 是 64 位的,但我想为 x64 和 x86 架构创建一个安装程序。
因此我编写了以下代码,试图从 Windows 注册表中获取 Office 的安装路径。而且,对于每个版本的 Office (2007 - 2013),它采用安装路径并附加我需要的其余路径。这就是我想要的结果。
[Code]
function GetHKLM() : Integer;
begin
if IsWin64 then
begin
Result := HKLM64;
end
else
begin
Result := HKEY_LOCAL_MACHINE;
end;
end;
function officeInstallDir(Param: string): string;
// This function takes the type of desired directory,
// verify the version of Office and returns the correct
// directory for style or bibform.
var
styleFolder, bibformFolder : string;
begin
// It verifies the Office version through the registry's subkey and it sets the correct Office's path.
if RegKeyExists(GetHKLM(), '\SOFTWARE\Microsoft\Office\15.0') then begin
styleFolder := '{userappdata}\Roaming\Microsoft\Bibliography\Style';
RegQueryStringValue(GetHKLM(), '\SOFTWARE\Microsoft\Office\15.0\Common', 'InstallRoot', bibformFolder);
bibformFolder := bibformFolder + '\1046\Bibliography';
end else begin
if RegKeyExists(GetHKLM(), '\SOFTWARE\Microsoft\Office\14.0') then begin
RegQueryStringValue(GetHKLM(), '\SOFTWARE\Microsoft\Office\14.0\Common', 'InstallRoot', styleFolder);
styleFolder := styleFolder + 'Bibliography\Style';
bibformFolder := styleFolder + '1046\Bibliography';
end else begin
if RegKeyExists(GetHKLM(), '\SOFTWARE\Microsoft\Office\12.0') then begin
RegQueryStringValue(GetHKLM(), '\SOFTWARE\Microsoft\Office\12.0\Common', 'InstallRoot', styleFolder);
styleFolder := styleFolder + 'Bibliography\Style';
bibformFolder := styleFolder + '1046\Bibliography';
end
end;
end;
// Set the result according Param passed (the first or second type of path).
if Param = 'style' then begin
result := styleFolder;
end else begin
result := bibformFolder;
end;
end;
使用其中一个路径,我尝试在 Inno Setup 中设置文件的安装路径 (DestDir),如下所示:
[Files]
Source: "E:\Google Drive\Informática\Bibword\Bibword Estilos\*"; DestDir: "{code:officeInstallDir|style}"; Flags: ignoreversion
Source: "E:\Google Drive\Informática\Bibword\Bibword file\BIBFORM.xml"; DestDir: "{code:officeInstallDir|bibform}"; Flags: ignoreversion
但是如果我传递参数 style 或 bibform,函数 officeInstallDir 应该帮助我为每一行设置正确的路径。但是 RegKeyExists 或 RegQueryStringValue 找不到注册表的子项。我什至尝试使用 GetHKLM() 函数,因为 64 位节点问题但没有成功。
有人愿意帮助我吗?
最佳答案
在 64 位系统上运行 32 位设置时,Inno 会自动将 HKLM 扩展为 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node 这意味着您不必在这里进行操作,除非有安装了 64 位办公室,可以在 64 位注册表分支中保存他的注册表信息。但是如果 IsWin64 = true,您可以对 HKLM64 进行额外检查。尽管您必须将其作为 String 传递,但不是 Integer,就像您在代码中所做的那样。
我会这样调用它(但我不太理解你代码的最后一部分,所以我只是粘贴了它):
[Code]
function officeInstallDir(Param: string): string;
var
styleFolder, bibformFolder : string;
begin
if RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot') then
begin
RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot', 'Path', bibformFolder);
styleFolder := ExpandConstant('{userappdata}') + '\Roaming\Microsoft\Bibliography\Style';
bibformFolder := bibformFolder + '\1046\Bibliography';
end
else begin
if RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot') then
begin
RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot', 'Path', styleFolder);
styleFolder := styleFolder + 'Bibliography\Style';
bibformFolder := styleFolder + '1046\Bibliography';
end
else begin
if RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Office\12.0\Common\InstallRoot') then
begin
RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Office\12.0\Common\InstallRoot', 'Path', styleFolder);
styleFolder := styleFolder + 'Bibliography\Style';
bibformFolder := styleFolder + '1046\Bibliography';
end;
end;
end;
// I quite don't get this part here:
if Param = 'style' then
begin
result := styleFolder;
end
else begin
result := bibformFolder;
end;
end;
关于windows - 如何从 Inno Setup 安装程序的注册表中获取 Office 的安装目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27895014/
我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div
总的来说,我对ruby还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用
我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack
我想用ruby编写一个小的命令行实用程序并将其作为gem分发。我知道安装后,Guard、Sass和Thor等某些gem可以从命令行自行运行。为了让gem像二进制文件一样可用,我需要在我的gemspec中指定什么。 最佳答案 Gem::Specification.newdo|s|...s.executable='name_of_executable'...endhttp://docs.rubygems.org/read/chapter/20 关于ruby-在Ruby中编写命令行实用程序