Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Аватара для Dodakaedr

Ветеран


Сообщения: 863
Благодарности: 262

Профиль | Отправить PM | Цитировать


Вот собрал, все выполняется кроме последнего, атрибут не становится обратно. Хэлп.
читать дальше »
Код: Выделить весь код
#ifdef UNICODE
  #define A "W"
#else
  #define A "A"
#endif

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=.

[Code]
function GetFileAttributes(lpFileName: string): integer;
external 'GetFileAttributes{#A}@kernel32.dll stdcall';

function SetFileAttributes(lpFileName: string; dwFileAttributes: integer): integer;
external 'SetFileAttributes{#A}@kernel32.dll stdcall';

procedure SetAttr();
var
FileName:string;
begin
FileName:= ExpandConstant('{sys}\drivers\etc\hosts');
if (GetFileAttributes(FileName) and FILE_ATTRIBUTE_NORMAL) = FILE_ATTRIBUTE_NORMAL then
SetFileAttributes(FileName, FILE_ATTRIBUTE_READONLY);
end;

procedure CurStepChanged(CurStep: TSetupStep);
var
   HostFile: TStringList;
   FileName: string;
begin
FileName:= ExpandConstant('{sys}\drivers\etc\hosts');
if (GetFileAttributes(FileName) and FILE_ATTRIBUTE_READONLY) = FILE_ATTRIBUTE_READONLY then
SetFileAttributes(FileName, FILE_ATTRIBUTE_NORMAL);
   HostFile := TStringList.Create;
   try
     with HostFile do
     if CurStep = ssPostInstall then
     begin
       LoadFromFile(ExpandConstant('{sys}\drivers\etc\hosts'));
       Add('127.0.0.1    tratata.ru');
       SaveToFile(ExpandConstant('{sys}\drivers\etc\hosts'));
     end;
   finally
     HostFile.free;
   end;
  SetAttr;
end;

-------
Inno Setup 5 Ultra Unicode


Отправлено: 23:13, 22-10-2014 | #1870