首页 > 解决方案 > Inno 设置 Windows 注册表无法捕获

问题描述

:-)

我已经在 Inno 设置中进行了一些编程,但现在我认为我无法只见树木不见森林。:-) 我想将“Copyfiles”部分中的一些自定义文件复制到位于注册表中的文件的安装路径中。为此,我调用“GetInstalledPath”并希望获取注册表信息。但是在 Copyfiles 部分中的消息框与输入消息“测试”之后是空的,并且文件也没有复制到正确的位置。我可以发誓它在早期版本中有效,可能是我改变了某事,或者有什么需要注意的?

非常感谢您的观看!

最良好的祝愿并保持健康!JH

function GetInstallPath(Param: String): String;
begin
  if Param = 'File1' then
    Result := 'C:\Program Files\FolderFile1'
   else if Param = 'InstPath32' then
    begin
      if RegGetSubkeyNames(HKLM32, 'Software\Programname', RegKeys) then
        begin
          if RegQueryStringValue(HKLM32,'Software\Programname' + '\'+ 'Versionnumber'+ 'Paths','InstallDirectory', Program_PATH2) then
              Result := Program_PATH2
          else
        end
      end
   else if Param = 'InstPath64' then
    begin
      if RegGetSubkeyNames(HKLM64, 'Software\Programname', RegKeys) then
        begin
          if RegQueryStringValue(HKLM64,'Software\Programname' + '\'+ 'Versionnumber+ 'Paths','InstallDirectory', Program_PATH3) then
              Result := Program_PATH3
          else
          MsgBox('InstPath64 ' + Program_PATH3, mbInformation, MB_OK);
        end
      end
end;

procedure WaitUntilInstalled();
var
  I: integer;
  count: integer;
begin
    count := 0;
    I := 0
    while (NOT FileExists(ExpandConstant('{tmp}\filename.txt'))) AND (count<90) DO
      begin
        count := count + 1;
        Sleep(1000);
      end;
end;


procedure CopyFiles(Param: String) ;
var 
SrcDir: String;
DestDir: String;
ResultCode: Integer;
Command: String;
  begin
      if Param = 'Example32' then
        begin
          SrcDir := '{tmp}\Customization';
          DestDir := GetInstallPath('InstPath32');
          Exec('md',ExpandConstant(DestDir),'',SW_SHOW, ewWaitUntilTerminated, ResultCode);
          Command :=  '"' + ExpandConstant(SrcDir) + '" "' +  ExpandConstant(DestDir) + '"' + ' /y /E /I';
          Exec('xcopy', Command, '',SW_SHOW, ewWaitUntilTerminated, ResultCode);
        end
         else if Param = 'Example64' then
        begin
          SrcDir := '{tmp}\Customization';
          DestDir := GetInstallPath('InstPath64');
         MsgBox('Test' + DestDir, mbInformation, MB_OK)
          Exec('md',ExpandConstant(DestDir),'',SW_SHOW, ewWaitUntilTerminated, ResultCode);
          Command :=  '"' + ExpandConstant(SrcDir) + '" "' +  ExpandConstant(DestDir) + '"' + ' /y /E /I';
          Exec('xcopy', Command, '',SW_SHOW, ewWaitUntilTerminated, ResultCode);
        end
end;

标签: filecopyregistryinno-setup

解决方案


推荐阅读