Прописывание данных в файл

tihiy_don

Старожил
Есть ли способ, чтобы осуществить запись выбранного пути установки приложение в файл с форматом .dat?
Там содержаться пути к ярлыку мода и оригинальной игры LOTR.
 

Хамик

Старожил
Пример (содержимое) файла покажите
 
Последнее редактирование:

Shegorat

Lord of Madness
Администратор
Есть ли способ, чтобы осуществить запись выбранного пути установки приложение в файл с форматом .dat?
.dat это не формат. Это всего лишь расширение названия файла. А внутри может быть что угодно, хоть json, хоть ini, хоть обычный текстовый файл
 

tihiy_don

Старожил
Пример (содержимое) файла покажите
Файл сюда в таком формате не прикрепляется, залил на яндекс диск. Ссылка: https://yadi.sk/d/-EC1Ojn7EcnYKg


.dat это не формат. Это всего лишь расширение названия файла. А внутри может быть что угодно, хоть json, хоть ini, хоть обычный текстовый файл
Полностью согласен с Вами, я ошибся .dat - расширение.
 

Shegorat

Lord of Madness
Администратор
Это бинарный файл в big endian
Код:
struct {
  uint32_t path_len;
  wchar_t  path[path_len];
  uint32_t dummy;
  uint32_t options_len;
  wchar_t  options[options_len];
}
Довольно сложно будет сделать такую запись силами самого InnoSetup. Т.к. возможности работы с памятью там весьма убогие.
 

tihiy_don

Старожил
Это бинарный файл в big endian
Код:
struct {
  uint32_t path_len;
  wchar_t  path[path_len];
  uint32_t dummy;
  uint32_t options_len;
  wchar_t  options[options_len];
}
Довольно сложно будет сделать такую запись силами самого InnoSetup. Т.к. возможности работы с памятью там весьма убогие.
Спасибо за ответ. Очень жаль конечно, пользователям придётся каждый раз вбивать путь :(
 

sergey3695

Ветеран
Модератор
@tihiy_don,
Код:
[Setup]
AppName=test
AppVerName=test
DefaultDirName={src}\123
Uninstallable=no
CreateUninstallRegKey=no
DirExistsWarning=no
OutputDir=.

[Languages]
Name: ru; MessagesFile: compiler:Languages\russian.isl

[Code]
#ifndef Unicode
const CharSize = 1;
#define A "A"
#else
const CharSize = 2;
#define A "W"
#endif

function CryptStringToBinary(
  sz: string; cch: LongWord; flags: LongWord; binary: string; var size: LongWord;
  skip: LongWord; flagsused: LongWord): Integer;
  external 'CryptStringToBinary{#A}@crypt32.dll stdcall';

const
  CRYPT_STRING_HEX = $04;

procedure WriteHexToFile(Hex: string; FileName: string);
var
  Stream: TFileStream;
  Buffer: string;
  Size: LongWord;
begin
  Stream := TFileStream.Create(FileName, fmCreate);

  try
    SetLength(Buffer, (Length(Hex) div 2*CharSize) + CharSize - 1);
    Size := Length(Hex) div 2;
    if (CryptStringToBinary(
          Hex, Length(Hex), CRYPT_STRING_HEX, Buffer, Size, 0, 0) = 0) or
       (Size <> Length(Hex) div 2) then
    begin
      RaiseException('Error decoding hex string');
    end;

    Stream.WriteBuffer(Buffer, Size);
  finally
    Stream.Free;
  end;
end;

function IntToHex(Value: Integer): string;
begin
  Result := Format('%.8x', [Value]);
end;

function StrToHex(str: string): string;
var
  i: Integer;
begin
  Result:= '';
  for i:= 1 to Length(str) do
    Result:= Result+'00'+Format('%.2x', [Ord(str[i]), Ord(str[i])]);
end;

var
  Str, Str2, Hex: string;

function CreateFile(
  lpFileName: string; dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes: DWORD;
  hTemplateFile: THandle): THandle;
  external 'CreateFile{#A}@kernel32.dll stdcall';

const
  OPEN_EXISTING = 3;
  FILE_SHARE_WRITE = 2;
  GENERIC_WRITE = $40000000;

function NextButtonClick(CurPage: Integer): Boolean;
begin
    Result := True;
  if CurPage = wpReady then
  begin
    Str := 'D:\Games\The Battle For Middle Earth\EP1\lotrbfme2ep1.exe';
    StringChangeEx(Str, '\', '/', True);
    Str:= StrToHex(Str);
    Str2 := StrToHex('D:\Games\AOTR6.0\aotr');
    Hex := IntToHex(Length(Str)/2)+Str+'00000000' +IntToHex(Length(Str2)/2+14)+'002D006D006F006400200022'+Str2+'0022';
  if not FileExists(ExpandConstant('{src}\file.dat')) then
    CreateFile(ExpandConstant('{src}\file.dat'), GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
    WriteHexToFile(Hex, ExpandConstant('{src}\file.dat'));
    MsgBox('Файл создан!', mbInformation, MB_OK);
    Result := False;
  end;
end;
Примерно вот так, можно создать файл. Надеюсь перекинуть код в CurPageChanged CurStepChanged и получать значение с edit не составит труда
 
Последнее редактирование:

tihiy_don

Старожил
Сергей, можете объяснить зачем брать значение с эдит? Там файл не стандартный с некими пробелами, каким образом я запишу их в файл?
 

Вложения

sergey3695

Ветеран
Модератор
Сергей, можете объяснить зачем брать значение с эдит?
Код:
    Str := 'D:\Games\The Battle For Middle Earth\EP1\lotrbfme2ep1.exe'; // Сюда, по типу WizardForm.DirEdit.text + '\EP1\lotrbfme2ep1.exe'
    StringChangeEx(Str, '\', '/', True);
    Str:= StrToHex(Str);
    Str2 := StrToHex('D:\Games\AOTR6.0\aotr'); // Здесь уже с другого edit текст по идее. ну или я без понятия как там.
 

tihiy_don

Старожил
То-есть, вы решили сделать способом присвоить переменный типа стринг данные значения, которые мне нужно и записать значения переменных в файл?

А как тогда быть с данным расширением файла вы не знаете? Так как если просто туда записать этот текст без пробела, лаунчер это не принимает.

Сам лаунчер выглядит так:
 

Вложения

sergey3695

Ветеран
Модератор
@tihiy_don,
не понял о чем речь, вот что я имел ввиду
Код:
[Setup]
AppName=test
AppVerName=test
DefaultDirName=D:\Games\The Battle For Middle Earth
Uninstallable=no
CreateUninstallRegKey=no
DirExistsWarning=no
OutputDir=.

[Languages]
Name: ru; MessagesFile: compiler:Languages\russian.isl

[Code]
var
  Label1: TLabel;
  NewEdit1: TNewEdit;
  NewButton1: TNewButton;

procedure DirOnClick(Sender: TObject);
var
  UserSelectDir: String;
begin
  UserSelectDir:= NewEdit1.Text;
if BrowseForFolder(SetupMessage(msgBrowseDialogLabel), UserSelectDir, False) then
  NewEdit1.Text:= UserSelectDir;
end;

procedure RedesignWizardForm;
begin
  Label1 := TLabel.Create(WizardForm);
  with Label1 do
  begin
    Parent := WizardForm.SelectDirPage;
    Caption := 'Расположение мода';
    Left := ScaleX(1);
    Top := ScaleY(104);
    Width := ScaleX(331);
    Height := ScaleY(13);
  end;

  NewEdit1 := TNewEdit.Create(WizardForm);
  with NewEdit1 do
  begin
    Parent := WizardForm.SelectDirPage;
    Left := ScaleX(0);
    Top := ScaleY(128);
    Width := ScaleX(332);
    Height := ScaleY(21);
    Text := 'D:\Games\AOTR6.0\aotr';
  end;

  NewButton1 := TNewButton.Create(WizardForm);
  with NewButton1 do
  begin
    Parent := WizardForm.SelectDirPage;
    Left := ScaleX(342);
    Top := ScaleY(128);
    Width := WizardForm.DirBrowseButton.Width;
    Height := WizardForm.DirBrowseButton.Height;
    Caption := WizardForm.DirBrowseButton.Caption;
    OnClick:= @DirOnClick;
  end;
end;

procedure InitializeWizard();
begin
  RedesignWizardForm;
end;

#ifndef Unicode
const CharSize = 1;
#define A "A"
#else
const CharSize = 2;
#define A "W"
#endif

function CryptStringToBinary(
  sz: string; cch: LongWord; flags: LongWord; binary: string; var size: LongWord;
  skip: LongWord; flagsused: LongWord): Integer;
  external 'CryptStringToBinary{#A}@crypt32.dll stdcall';

const
  CRYPT_STRING_HEX = $04;

procedure WriteHexToFile(Hex: string; FileName: string);
var
  Stream: TFileStream;
  Buffer: string;
  Size: LongWord;
begin
  Stream := TFileStream.Create(FileName, fmCreate);

  try
    SetLength(Buffer, (Length(Hex) div 2*CharSize) + CharSize - 1);
    Size := Length(Hex) div 2;
    if (CryptStringToBinary(
          Hex, Length(Hex), CRYPT_STRING_HEX, Buffer, Size, 0, 0) = 0) or
       (Size <> Length(Hex) div 2) then
    begin
      RaiseException('Error decoding hex string');
    end;

    Stream.WriteBuffer(Buffer, Size);
  finally
    Stream.Free;
  end;
end;

function IntToHex(Value: Integer): string;
begin
  Result := Format('%.8x', [Value]);
end;

function StrToHex(str: string): string;
var
  i: Integer;
begin
  Result:= '';
  for i:= 1 to Length(str) do
    Result:= Result+'00'+Format('%.2x', [Ord(str[i]), Ord(str[i])]);
end;

var
  Str, Str2, Hex: string;

function CreateFile(
  lpFileName: string; dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes: DWORD;
  hTemplateFile: THandle): THandle;
  external 'CreateFile{#A}@kernel32.dll stdcall';

const
  OPEN_EXISTING = 3;
  FILE_SHARE_WRITE = 2;
  GENERIC_WRITE = $40000000;

function NextButtonClick(CurPage: Integer): Boolean;
begin
    Result := True;
  if CurPage = wpReady then
  begin
//    Str := 'D:\Games\The Battle For Middle Earth\EP1\lotrbfme2ep1.exe';
    Str:= WizardForm.DirEdit.text + '\EP1\lotrbfme2ep1.exe';
    StringChangeEx(Str, '\', '/', True);
    Str:= StrToHex(Str);
//    Str2 := StrToHex('D:\Games\AOTR6.0\aotr');
    Str2 := StrToHex(NewEdit1.text);
    Hex := IntToHex(Length(Str)/2)+Str+'00000000' +IntToHex(Length(Str2)/2+14)+'002D006D006F006400200022'+Str2+'0022';
  if not FileExists(ExpandConstant('{src}\file.dat')) then
    CreateFile(ExpandConstant('{src}\file.dat'), GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
    WriteHexToFile(Hex, ExpandConstant('{src}\file.dat'));
    MsgBox('Файл создан!', mbInformation, MB_OK);
    Result := False;
  end;
end;
002D006D006F006400200022 это -mod "
А как тогда быть с данным расширением файла вы не знаете?
проблема в том, что вы не понимаете что за код я предоставил. ну или я не понимаю 🤔
 

tihiy_don

Старожил
Согласен, я очень плохо понимаю. ;(
А можно это реализовать чтобы файл автоматически создавался после установки моего репака?
Получается, мне необходимо осуществить вызов функций в секции RUN?
code_language.pascal:
;установщик репак

#include "botva2.iss"
#include "BASS_Module.iss"

#define MyAppName "Age of the Ring"
#define MyAppVersion "5.1"
#define MyAppPublisher "Tihiy_Don"
#define MyAppURL "https://vk.com/ageofthering"
#define MyAppExeName "lotrbfme2ep1.exe"

[Setup]
; Примечание: Значение AppId является уникальным идентификатором для этого приложения.
; Не используйте одно и тоже значение AppId для разных приложений.
; (Для создания нового значения GUID, выберите в меню "Инструменты" пункт "Создать GUID".)
AppId={{9C84BF97-B765-45A3-8E58-AA947379C8B5}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName=Age of the Ring 5.1 Repack by Tihiy_don
AllowNoIcons=yes
InfoBeforeFile=D:\инсталл властелин колец\before.rtf
InfoAfterFile=D:\инсталл властелин колец\информация.rtf
OutputDir=D:\инсталл властелин колец\Age of the Ring 5.1 - Repack by Tihiy_Don
OutputBaseFilename=setup
SetupIconFile=D:\инсталл властелин колец\aotr.ico
WizardSmallImageFile=small.bmp
DiskSpanning=yes
SlicesPerDisk=1
DiskSliceSize=2100000000
DiskClusterSize=4096
ReserveBytes=0
Compression=lzma/ultra
InternalCompressLevel=ultra64
SolidCompression=true
FlatComponentsList=yes
DisableDirPage=no

[Languages]
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1

[Files]
//Source: "b2p.dll"; DestDir : {tmp}; Flags: dontcopy
//Source: "botva2.dll"; DestDir : {tmp}; Flags: dontcopy
//Source: "bass.dll"; DestDir: {tmp}; Flags: dontcopy
//Source: "CallbackCtrl.dll"; DestDir : {tmp}; Flags: dontcopy
Source: "music.mp3"; DestDir : {tmp}; Flags: dontcopy
Source: BASS_Files\*; DestDir : {tmp}; Flags: dontcopy

Source: "D:\games\Аge of the Ring\Age of the Ring\lotrbfme2ep1.exe"; DestDir: "{app}\Age of the Ring\"; Flags: ignoreversion
Source: "D:\games\Аge of the Ring\LOTR\CDKeyFixer\CDKeyFixer.exe"; DestDir: "{app}\LOTR\CDKeyFixer\"; Flags: ignoreversion
;========================================= Файлы ======================================================;
Source: "D:\games\Аge of the Ring\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;             
;=======================================================================================================;

//для установки дов онлайна///////////////////
Source: "D:\инсталл властелин колец\Readme.txt"; DestDir: "{app}"
Source: "D:\инсталл властелин колец\Информация.rtf"; DestDir: "{app}"
//////////////////////////////////////////////
//////===========Пихаем в Appdate папку с файлом======/////
Source: "D:\инсталл властелин колец\Options.ini"; DestDir: "{userappdata}\Битва за Средиземье - Мои файлы"
Source: "D:\инсталл властелин колец\Options.ini"; DestDir: "{userappdata}\Властелин Колец, Под знаменем Короля-чародея - Мои файлы"
[Components]

[code]

// Процедура для изменения громкости
// Можно добавить в сам модуль BASS_Module.iss
//------------------------------------------------------------------------------
procedure BASS_SetVolume(Pos: DWORD);
var
  nLeft, bLeft, bTop, bWidth, bHeight: Integer;
begin
  if (Pos >= 0) and (Pos <= 100) then begin
  BASSChangePos(Pos);
  nLeft:= BASS_VolBar.MinLeft + round(BASS_VolBar.BarWidth*BASS_Cfg.Volume/100);
  if (nLeft<BASS_VolBar.MinLeft) then nLeft:= BASS_VolBar.MinLeft;
  if (nLeft>BASS_VolBar.MaxLeft) then nleft:= BASS_VolBar.MaxLeft;
  BtnGetPosition(BASS_VolBar.BarDote, bLeft, bTop, bWidth, bHeight);
  BtnSetPosition(BASS_VolBar.BarDote, nLeft, bTop, bWidth, bHeight);
  ImgApplyChanges(BASS_VolBar.Parent); // вроде не нужно, но навсякий написал
 end;
end;
//------------------------------------------------------------------------------

procedure InitializeWizard();
begin
ExtractTemporaryFile('bass.dll');
ExtractTemporaryFile('music.mp3');
ExtractTemporaryFile('MusicButton.png')
ExtractTemporaryFile('volmax.png')
ExtractTemporaryFile('volmin.png')
ExtractTemporaryFile('volpb.png')
ExtractTemporaryFile('volpbt.png')
ExtractTemporaryFile('voldote.png')
ExtractTemporaryFile('botva2.dll')
ExtractTemporaryFile('CallbackCtrl.dll')
                                                        
Bass_Init ('{tmp}\music.mp3');
BASS_CreateMediaPlayer(WizardForm, '{tmp}\volmax.png', '{tmp}\volmin.png', '{tmp}\volpb.png', '{tmp}\volpbt.png', '{tmp}\voldote.png', 20, 320, 150, True);
BASS_SetVolume(15);
end;

procedure DeinitializeSetup();
begin
Bass_DeInit;
gdipShutdown
end;

begin
  WizardForm.TypesCombo.Visible:= False;
end.

[Registry]
//Реестр The Battle for Middle-earth II
Root: HKLM; Subkey: "Software\Electronic Arts"; Flags: createvalueifdoesntexist uninsdeletekeyifempty
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts"; Flags: createvalueifdoesntexist uninsdeletekey
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Battle for Middle-earth II"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}\LOTR\"
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "Language"; ValueData: "russian"
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Battle for Middle-earth II"; ValueType: dword; ValueName: "MapPackVersion"; ValueData: "65536"
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Battle for Middle-earth II"; ValueType: dword; ValueName: "UseLocalUserMaps"; ValueData: "0"
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "UserDataLeafName"; ValueData: "Битва за Средиземье - Мои файлы"
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Battle for Middle-earth II"; ValueType: dword; ValueName: "Version"; ValueData: "65542"

Root: HKLM; SubKey: "Software\Electronic Arts\Electronic Arts\The Battle for Middle-earth II\ergc"; ValueType: string; ValueName: ; ValueData: "YKQQNLLGYSYXMWYACJFW"

//Реестр The Lord of the Rings, The Rise of the Witch-king
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; Flags: uninsdeletekey; Check: not IsWin64
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}\LOTR\Ep1\"
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "Language"; ValueData: "russian"
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: dword; ValueName: "MapPackVersion"; ValueData: "131072"
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: dword; ValueName: "UseLocalUserMaps"; ValueData: "0"
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "UserDataLeafName"; ValueData: "Властелин Колец, Под знаменем Короля-чародея - Мои файлы"
Root: HKLM; Subkey: "Software\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: dword; ValueName: "Version"; ValueData: "131073"

Root: HKLM; SubKey: "Software\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king\ergc"; ValueType: string; ValueName: ; ValueData: "PB4CC5AFS3BUQSZMKSDD"

///////////////////
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; Flags: uninsdeletekey
///////////////////
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II\1.0"; ValueType: string; ValueName: "DisplayName"; ValueData: "Битва за Средиземье™ II"
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II\1.0"; ValueType: dword; ValueName: "Language"; ValueData: "16"
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II\1.0"; ValueType: string; ValueName: "LanguageName"; ValueData: "Russian"
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "CacheSize"; ValueData: "5441287168"
//Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "CD Drive"; ValueData: "{src}"
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "DisplayName"; ValueData: "Битва за Средиземье™ II"
//Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "Folder"; ValueData: "{group}"
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "Install Dir"; ValueData: "{app}\LOTR\"
//Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "Installed From"; ValueData: "{src}"
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "Language"; ValueData: "Russian"
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "Locale"; ValueData: "ru"
//Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "Patch URL"; ValueData: "http://transtest.ea.com/Electronic Arts/The Battle for Middle-earth 2/NorthAmerica"
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "Product GUID"; ValueData: "{{2A9F95AB-65A3-432c-8631-B8BC5BF7477A}"
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "Region"; ValueData: "NorthAmerica"
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "Registration"; ValueData: "SOFTWARE\Electronic Arts\Electronic Arts\The Battle for Middle-earth II\ergc"
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "Suppression Exe"; ValueData: "rtsi.exe"
Root: HKLM; Subkey: "Software\Electronic Arts\The Battle for Middle-earth II"; ValueType: string; ValueName: "SwapSize"; ValueData: "0"

Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king\1.0"; ValueType: string; ValueName: "DisplayName"; ValueData: "Под знаменем Короля-чародея™"
Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king\1.0"; ValueType: dword; ValueName: "Language"; ValueData: "16"
Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king\1.0"; ValueType: string; ValueName: "LanguageName"; ValueData: "Russian"
Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "CacheSize"; ValueData: "3139187712"
//Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "CD Drive"; ValueData: "{src}"
Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "DisplayName"; ValueData: "Под знаменем Короля-чародея™"
//Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "Folder"; ValueData: "{group}"
Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "Install Dir"; ValueData: "{app}\LOTR\Ep1\"
//Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "Installed From"; ValueData: "{src}"
Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "Language"; ValueData: "Russian"
Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "Locale"; ValueData: "ru"
//Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "Patch URL"; ValueData: "http://transtest.ea.com/Electronic Arts/The Battle for Middle-earth 2/NorthAmerica"
Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "Product GUID"; ValueData: "{{B931FB80-537A-4600-00AD-AC5DEDB6C25B}"
Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "Region"; ValueData: "NorthAmerica"
Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "Registration"; ValueData: "SOFTWARE\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king\ergc"
Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "Suppression Exe"; ValueData: "rtsi.exe"
Root: HKLM; Subkey: "Software\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king"; ValueType: string; ValueName: "SwapSize"; ValueData: "0"

//нечто
Root: HKLM; SubKey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2.exe; ValueType: string; ValueName: Path; ValueData: {app}\LOTR\
Root: HKLM; SubKey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2.exe; ValueType: string; ValueData: {app}\LOTR\lotrbfme2.exe
Root: HKLM; SubKey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2.exe; ValueType: dword; ValueName: DirectX Installed; ValueData: $00000000
Root: HKLM; SubKey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2.exe; ValueType: string; ValueName: Game Registry; ValueData: SOFTWARE\Electronic Arts\The Battle for Middle-earth II
Root: HKLM; SubKey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2.exe; ValueType: dword; ValueName: Installed; ValueData: $00000001
Root: HKLM; SubKey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2.exe; ValueType: dword; ValueName: Restart; ValueData: $00000000
Root: HKLM; SubKey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe; ValueType: dword; ValueName: Restart; ValueData: $00000000
Root: HKLM; SubKey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe; ValueType: dword; ValueName: DirectX Installed; ValueData: $00000000
Root: HKLM; SubKey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe; ValueType: string; ValueName: Game Registry; ValueData: SOFTWARE\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king
Root: HKLM; SubKey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe; ValueType: string; ValueName: Path; ValueData: {app}\LOTR\Ep1
Root: HKLM; SubKey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe; ValueType: dword; ValueName: Installed; ValueData: $00000001
Root: HKLM; SubKey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe; ValueType: string; ValueData: {app}\LOTR\Ep1\lotrbfme2ep1.exe
Root: HKLM; SubKey: SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2.exe; ValueType: string; ValueName: Path; ValueData: {app}\LOTR\
Root: HKLM; SubKey: SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2.exe; ValueType: string; ValueData: {app}\LOTR\lotrbfme2.exe
Root: HKLM; SubKey: SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2.exe; ValueType: dword; ValueName: DirectX Installed; ValueData: $00000000
Root: HKLM; SubKey: SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2.exe; ValueType: string; ValueName: Game Registry; ValueData: SOFTWARE\Electronic Arts\The Battle for Middle-earth II
Root: HKLM; SubKey: SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2.exe; ValueType: dword; ValueName: Installed; ValueData: $00000001
Root: HKLM; SubKey: SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2.exe; ValueType: dword; ValueName: Restart; ValueData: $00000000
Root: HKLM; SubKey: SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe; ValueType: dword; ValueName: Restart; ValueData: $00000000
Root: HKLM; SubKey: SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe; ValueType: dword; ValueName: DirectX Installed; ValueData: $00000000
Root: HKLM; SubKey: SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe; ValueType: string; ValueName: Game Registry; ValueData: SOFTWARE\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king
Root: HKLM; SubKey: SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe; ValueType: string; ValueName: Path; ValueData: {app}\LOTR\Ep1
Root: HKLM; SubKey: SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe; ValueType: dword; ValueName: Installed; ValueData: $00000001
Root: HKLM; SubKey: SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe; ValueType: string; ValueData: {app}\LOTR\Ep1\lotrbfme2ep1.exe
[Icons]
Name: "{group}\Запустить игру"; IconFilename: "{app}\Age of the Ring\launcher_files\aotr.ico"; Filename: "{app}\Age of the Ring\lotrbfme2ep1.exe"; WorkingDir: "{app}\Age of the Ring"
Name: "{group}\Удалить игру"; Filename: "{uninstallexe}"; WorkingDir: "{app}"
Name: "{group}\Наша группа Вконтакте"; Filename: "{#MyAppURL}"
Name: "{commondesktop}\Age of the Ring 5.1"; IconFilename: "{app}\Age of the Ring\launcher_files\aotr.ico"; Filename: "{app}\Age of the Ring\lotrbfme2ep1.exe"; Tasks: desktopicon
Name: "{commondesktop}\CDKeyFixer"; Filename: "{app}\LOTR\CDKeyFixer\CDKeyFixer.exe"; Tasks: desktopicon; WorkingDir: "{app}\LOTR\CDKeyFixer"
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

[Run]
Filename: "{app}\Age of the Ring\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent runascurrentuser
Filename: "{app}\Readme.txt"; Description: "Прочитать гайд для игры по сети"; Flags: postinstall shellexec skipifsilent

[UninstallDelete]
Type: files; Name: "{app}\*.ini"
Type: files; Name: "{app}\Log\*.log"
Type: dirifempty; Name: "{app}\Log"
 

sergey3695

Ветеран
Модератор
@tihiy_don,
Код:
[Setup]
AppName=test
AppVerName=test
DefaultDirName=D:\Games\The Battle For Middle Earth
OutputDir=.

[Languages]
Name: ru; MessagesFile: compiler:Languages\russian.isl

[UninstallDelete]
Type: FilesAndOrDirs; Name: {app};

[Code]
var
  Label1: TLabel;
  NewEdit1: TNewEdit;
  NewButton1: TNewButton;

procedure DirOnClick(Sender: TObject);
var
  UserSelectDir: String;
begin
  UserSelectDir:= NewEdit1.Text;
if BrowseForFolder(SetupMessage(msgBrowseDialogLabel), UserSelectDir, False) then
  NewEdit1.Text:= UserSelectDir;
end;

procedure RedesignWizardForm;
begin
  Label1 := TLabel.Create(WizardForm);
  with Label1 do
  begin
    Parent := WizardForm.SelectDirPage;
    Caption := 'Расположение мода';
    Left := ScaleX(1);
    Top := ScaleY(104);
    Width := ScaleX(331);
    Height := ScaleY(13);
  end;

  NewEdit1 := TNewEdit.Create(WizardForm);
  with NewEdit1 do
  begin
    Parent := WizardForm.SelectDirPage;
    Left := ScaleX(0);
    Top := ScaleY(128);
    Width := ScaleX(332);
    Height := ScaleY(21);
    Text := 'D:\Games\AOTR6.0\aotr';
  end;

  NewButton1 := TNewButton.Create(WizardForm);
  with NewButton1 do
  begin
    Parent := WizardForm.SelectDirPage;
    Left := ScaleX(342);
    Top := ScaleY(128);
    Width := WizardForm.DirBrowseButton.Width;
    Height := WizardForm.DirBrowseButton.Height;
    Caption := WizardForm.DirBrowseButton.Caption;
    OnClick:= @DirOnClick;
  end;
end;

procedure InitializeWizard();
begin
  RedesignWizardForm;
end;

#ifndef Unicode
const CharSize = 1;
#define A "A"
#else
const CharSize = 2;
#define A "W"
#endif

function CryptStringToBinary(
  sz: string; cch: LongWord; flags: LongWord; binary: string; var size: LongWord;
  skip: LongWord; flagsused: LongWord): Integer;
  external 'CryptStringToBinary{#A}@crypt32.dll stdcall';

const
  CRYPT_STRING_HEX = $04;

procedure WriteHexToFile(Hex: string; FileName: string);
var
  Stream: TFileStream;
  Buffer: string;
  Size: LongWord;
begin
  Stream := TFileStream.Create(FileName, fmCreate);

  try
    SetLength(Buffer, (Length(Hex) div 2*CharSize) + CharSize - 1);
    Size := Length(Hex) div 2;
    if (CryptStringToBinary(
          Hex, Length(Hex), CRYPT_STRING_HEX, Buffer, Size, 0, 0) = 0) or
       (Size <> Length(Hex) div 2) then
    begin
      RaiseException('Error decoding hex string');
    end;

    Stream.WriteBuffer(Buffer, Size);
  finally
    Stream.Free;
  end;
end;

function IntToHex(Value: Integer): string;
begin
  Result := Format('%.8x', [Value]);
end;

function StrToHex(str: string): string;
var
  i: Integer;
begin
  Result:= '';
  for i:= 1 to Length(str) do
    Result:= Result+'00'+Format('%.2x', [Ord(str[i]), Ord(str[i])]);
end;

var
  Str, Str2, Hex: string;

function CreateFile(
  lpFileName: string; dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes: DWORD;
  hTemplateFile: THandle): THandle;
  external 'CreateFile{#A}@kernel32.dll stdcall';

const
  OPEN_EXISTING = 3;
  FILE_SHARE_WRITE = 2;
  GENERIC_WRITE = $40000000;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then
  begin
//    Str := 'D:\Games\The Battle For Middle Earth\EP1\lotrbfme2ep1.exe';
//    Str:= WizardForm.DirEdit.text + '\EP1\lotrbfme2ep1.exe';
    Str:= ExpandConstant('{app}\EP1\lotrbfme2ep1.exe');
    StringChangeEx(Str, '\', '/', True);
    Str:= StrToHex(Str);
//    Str2 := StrToHex('D:\Games\AOTR6.0\aotr');
    Str2 := StrToHex(NewEdit1.text);
    Hex := IntToHex(Length(Str)/2)+Str+'00000000' +IntToHex(Length(Str2)/2+14)+'002D006D006F006400200022'+Str2+'0022';
  if not FileExists(ExpandConstant('{app}\file.dat')) then
    CreateFile(ExpandConstant('{app}\file.dat'), GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
    WriteHexToFile(Hex, ExpandConstant('{app}\file.dat'));
  end;
end;
вот пример, после установки создается файл по пути установки. (если другое расположение, то меняйте сами уже). в скрипт тоже сами.
 

tihiy_don

Старожил
А нет ли возможности создания ярлыка с заданными параметрами? Так делает инсталлятор мода:

1608108041399.png

Как бы он ссылается на файл запуска основной игры, но имеет такие параметры.
Объект: "D:\games\age of the ring\LOTR\Ep1\lotrbfme2ep1.exe" -mod "D:\games\age of the ring\aotr\aotr"
Рабочая папка: "D:\games\age of the ring\LOTR\Ep1"
 

vint56

Ветеран
Проверенный
tihiy_don


[Icons]
Name: {commondesktop}\age of the ring; Filename: {app}\LOTR\Ep1\lotrbfme2ep1.exe; Parameters: -mod {app}\aotr\aotr; WorkingDir: {app}\LOTR\Ep1
 
Последнее редактирование:

tihiy_don

Старожил
tihiy_don


[Icons]
Name: {commondesktop}\age of the ring; Filename: {app}\LOTR\Ep1\lotrbfme2ep1.exe; Parameters: -mod {app}\aotr\aotr; WorkingDir: {app}\LOTR\Ep1
У вас Parameters:
Код:
-mod {app}\aotr\aotr;
Я пытаюсь скомпилировать с таким параметром:
Код:
Name: "{commondesktop}\Age of the Ring"; Filename:" D:\games\age of the ring\LOTR\Ep1lotrbfme2ep1.exe"; Parameters: "D:\games\age of the ring\LOTR\Ep1\lotrbfme2ep1.exe" -mod "D:\games\age of the ring\aotr\aotr"; WorkingDir: "D:\games\age of the ring\LOTR\Ep1"; Tasks: desktopicon
Но компилятор ругается,нельзя сделать параметр чтобы был с таким значением, например:?
Parameters: "D:\games\age of the ring\LOTR\Ep1\lotrbfme2ep1.exe" -mod "D:\games\age of the ring\aotr\aotr";
 

vint56

Ветеран
Проверенный
#define GameName "Age of the Ring"

[Setup]
AppName=Age of the Ring
AppVersion=1.0
DefaultDirName={code:NoSD}\Games\{#GameName}
DefaultGroupName={#GameName}

[Files]
Source: "C:\age of the ring\LOTR\Ep1\lotrbfme2ep1.exe"; DestDir: "{app}\LOTR\Ep1\"; Flags: ignoreversion

[Icons]
Name: {commondesktop}\age of the ring; Filename: {app}\LOTR\Ep1\lotrbfme2ep1.exe; Parameters: -mod {app}\aotr\aotr; WorkingDir: {app}\LOTR\Ep1

Код:
function GetLogicalDrives: DWORD; external 'GetLogicalDrives@kernel32.dll stdcall';
function GetDriveType(lpRootPathName: PAnsiChar): Cardinal; external 'GetDriveTypeA@kernel32.dll stdcall';

const
  DRIVE_FIXED = 3;

function NoSD(s: string): string;
var
  x, bit, i: Integer;
  tp: Cardinal;
  sd: string;
begin
  sd:= ExpandConstant('{sd}');
  Result:= sd;
  // Вызываем функцию WinAPI
  // Функция возвращает битовую маску установленных логических дисков.
  // Бит 0 определяет наличие диска А:, бит 1 - диска B и т.д.
  x:= GetLogicalDrives;
  if x <> 0 then
  // цикл по полученным битам переменной X
  for i:= 1 to 64 do
    begin
      // Накладываем битовую маску для выделения бита с поряковым номером 0
      bit:= x and 1;
      // нашли логический диск...
      if bit = 1 then
        begin
          // определяем тип логического диска
          tp:= GetDriveType(PAnsiChar(Chr(64 + i) + ':'));
          if tp = DRIVE_FIXED then
          // если диск не является системным
          if Chr(64 + i) <> Copy(sd, 1, 1) then
            begin
              Result:= Chr(64 + i) + ':';
              Break;
            end;
        end;
      // побитовый сдвиг вправо
      x:= x shr 1;
    end;
end;[/SPOILER]
 
Последнее редактирование:
Сверху