на держи, думай что делаешь в следующий раз.
Я тебе там все секции объединил, левак отрезал, DeinitializeSetup и InitializeSetup поправил.
- Вложения
Код: Выделить всё
function GetSystemMetrics(nIndex:Integer):integer; external 'GetSystemMetrics@user32.dll stdcall delayload';
procedure InitializeWizard();
begin
WizardForm.CancelButton.BringToFront;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID=wpInstalling then
begin
WizardForm.Bevel.Hide;
WizardForm.Bevel1.Hide;
WizardForm.BorderStyle:=bsDialog;
WizardForm.MainPanel.Visible:=False;
WizardForm.Width:=ScaleX(320);
WizardForm.Height:=ScaleY(127);
WizardForm.InnerNotebook.Left:=ScaleX(7);
WizardForm.InnerNotebook.Top:=ScaleY(7);
WizardForm.InnerNotebook.Width:=ScaleX(300);
WizardForm.StatusLabel.Left:=ScaleX(0);
WizardForm.StatusLabel.Top:=ScaleY(0);
WizardForm.StatusLabel.Width:=WizardForm.InnerNotebook.Width;
WizardForm.FileNameLabel.Left:=ScaleX(0);
WizardForm.FileNameLabel.Top:=ScaleY(17);
WizardForm.FileNameLabel.Width:=WizardForm.InnerNotebook.Width;
WizardForm.ProgressGauge.Top:=ScaleY(37);
WizardForm.ProgressGauge.Left:=ScaleX(0);
WizardForm.ProgressGauge.Width:=WizardForm.InnerNotebook.Width;
WizardForm.CancelButton.Left:=ScaleX(122);
WizardForm.CancelButton.Top:=ScaleY(70);
WizardForm.Left:=GetSystemMetrics(16)-GetSystemMetrics(16)+ ScaleX(5);
WizardForm.Top:=GetSystemMetrics(17)-ScaleX(110);
end;
if CurPageID=wpFinished
then
begin
WizardForm.Width:=502;
WizardForm.Height:=392;
WizardForm.Position:=poScreenCenter;
end
end;
На базе примера от [b]Avengerz[/b]
Цитата [b]Serega[/b]:
необходимо соединение с интернетом [url=viewtopic.php?p=2799628#p2799628]»[/url]
А если нет интернета, то нет и внешнего IP [img]images/smilies/new/smile.gif[/img]Код: Выделить всё
[Setup]
AppName=My Program
AppVerName=My Program v 1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
OutputDir=.
Compression=lzma2/ultra
InternalCompressLevel=ultra
SolidCompression=yes
[Languages]
Name: rus; MessagesFile: compiler:Languages\Russian.isl
[Code]
{===============================================================================}
{ Script name: GetMyIP.iss }
{ Script version: 1.0 }
{ Author: Serega, http://forum.oszone.net/member.php?userid=88670 }
{ }
{ This script shows how to learn your IP }
{ Этот скрипт показывает, как узнать свой IP }
{===============================================================================}
var
pnl: TPanel;
lbl: TLabel;
Memo: TMemo;
Button: TButton;
function GetHtmlSource(const url: string): string;
var
vHttp: Variant;
begin
try
vHttp := CreateOleObject('Microsoft.XMLHTTP');
vHttp.open('GET', url, False);
vHttp.send;
Result := vHttp.responseText;
except
Result := 'Возникла ошибка при обращении к серверу, проверьте настройки соединения.';
end;
end;
procedure ButtonClick(Sender: TObject);
var
strHtml: string;
begin
try
Memo.Clear;
lbl.Caption := '';
strHtml := GetHtmlSource('http://2ip.ru/');
Memo.Lines.Text := strHtml;
if (strHtml <> '') and (Pos('ошибка', Copy(strHtml, 1, 20)) = 0) then
begin
Delete(strHtml, 1, Pos('class="ip"', strHtml));
Delete(strHtml, 1, Pos('<big', strHtml));
Delete(strHtml, 1, Pos('>', strHtml));
SetLength(strHtml, Pos('<', strHtml)-1);
lbl.Caption := 'Ваш IP адрес: ' + Trim(strHtml);
end;
finally
SetLength(strHtml, 0);
end;
end;
procedure InitializeWizard();
begin
pnl := TPanel.Create(WizardForm);
with pnl do
begin
Parent := WizardForm;
Left := 0;
Top := 0;
Align := alClient;
end;
WizardForm.CancelButton.Parent := pnl;
with TLabel.Create(WizardForm) do
begin
Parent := pnl;
AutoSize := True;
Left := ScaleX(15);
Top := ScaleY(10);
Caption := 'Исходный код страницы (http://2ip.ru/):';
end;
Memo := TMemo.Create(WizardForm);
with Memo do
begin
Parent := pnl;
SetBounds(ScaleX(15), ScaleY(30), WizardForm.ClientWidth - ScaleX(30), ScaleY(285));
ReadOnly := True;
ScrollBars := ssBoth;
Text := '';
end;
Button := TButton.Create(WizardForm);
with Button do
begin
Parent := pnl;
SetBounds(ScaleX(300), WizardForm.CancelButton.Top, ScaleX(85), ScaleY(23));
Caption := 'Узнать IP';
OnClick := @ButtonClick;
end;
lbl := TLabel.Create(WizardForm);
with lbl do
begin
Parent := pnl;
AutoSize := True;
Left := ScaleX(25);
Top := ScaleY(328);
Font.Size := 12;
end;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm := False;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
WizardForm.CancelButton.Caption := 'Закрыть';
end;Код: Выделить всё
[Setup]
AppName=My Program
AppVerName=My Program v 1.5
DefaultDirName={pf}\My Program
OutputDir=.
Compression=lzma2/ultra
InternalCompressLevel=ultra
SolidCompression=yes
[Languages]
Name: rus; MessagesFile: compiler:Languages\Russian.isl
[CustomMessages]
rus.otherGroup=Прочее:
rus.pointDesc=Создать системную контрольную точку (рекомендуется)
rus.pointMsg=Создание контрольной точки...
[Tasks]
Name: restorepoint; Description: {cm:pointDesc}; GroupDescription: {cm:otherGroup}; MinVersion: 0,5.1
[Files]
Source: compiler:Examples\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
[Code]
{===============================================================================}
{ Script name: SetRestorePoint.iss }
{ Script version: 1.0 }
{ Author: Serega, http://forum.oszone.net/member.php?userid=88670 }
{ }
{ This script shows how to create restore point before install }
{ Этот скрипт показывает, как создать контрольную точку перед установкой }
{ }
{ function SetRestorePoint(const PointName: string): Boolean; }
{===============================================================================}
const
// Description http://msdn.microsoft.com/en-us/library/aa378847%28VS.85%29.aspx
// Restore point type
APPLICATION_INSTALL = 0;
APPLICATION_UNINSTALL = 1;
DEVICE_DRIVER_INSTALL = 10;
MODIFY_SETTINGS = 12;
CANCELLED_OPERATION = 13;
// Event type
BEGIN_SYSTEM_CHANGE = 100;
END_SYSTEM_CHANGE = 101;
BEGIN_NESTED_SYSTEM_CHANGE = 102;
END_NESTED_SYSTEM_CHANGE = 103;
function SetRestorePoint(const PointName: string): Boolean;
var
vObj, SR: Variant;
begin
vObj := CreateOleObject('ScriptControl');
vObj.Language := 'VBScript';
SR := vObj.eval('GetObject("winmgmts:\\.\root\default:SystemRestore")');
Result := SR.CreateRestorePoint(PointName, APPLICATION_INSTALL, BEGIN_SYSTEM_CHANGE) = 0;
end;
procedure CurPageChanged(CurPageID: Integer);
var
msg: string;
begin
if (CurPageID = wpInstalling) and IsTaskSelected('restorepoint') then
try
msg := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := ExpandConstant('{cm:pointMsg}');
WizardForm.Repaint;
// создаём контрольную точку
SetRestorePoint('Установка {#SetupSetting("AppName")}');
WizardForm.StatusLabel.Caption := msg;
finally
SetLength(msg, 0);
end;
end;Код: Выделить всё
function GetMACAddress(): string;
var
ResultCode: Integer;
strArray: TArrayOfString;
Temp: string;
strMAC: string;
strLen: integer;
i: integer;
begin
Result:= '';
Exec('cmd.exe', '/c ipconfig /all >> ' + ExpandConstant('{tmp}\adapter.info'), '', SW_HIDE,
ewWaitUntilTerminated, ResultCode);
LoadStringsFromFile(ExpandConstant('{tmp}\adapter.info'), strArray);
for i := 1 to GetArrayLength(strArray)-1 do begin
strLen:= Length(strArray[i]);
Temp:=strArray[i-1];
if strLen > 16 then
begin
// MsgBox(IntToStr(Pos('VMware', Temp)), mbInformation, MB_OK);
MsgBox(Temp, mbInformation, MB_OK);
if (CompareStr('-', strArray[i][strLen-2] ) = 0) and
(CompareStr('-', strArray[i][strLen-5] ) = 0) and
(CompareStr('-', strArray[i][strLen-8] ) = 0) and
(CompareStr('-', strArray[i][strLen-11]) = 0) and
(CompareStr('-', strArray[i][strLen-14]) = 0) and
(Pos('VMware', Temp) = 0) and
(Pos('Hamachi', Temp) = 0) then
Result:= Result + #10#13 + Copy(strArray[i], strLen-16, 17);
end;
end;
end;Код: Выделить всё
#include "ConvertString.iss"
function GetMACAddress(): string;
var
ResultCode: Integer;
strArray: TArrayOfString;
Temp: string;
strMAC: string;
strLen: integer;
i: integer;
begin
Result := '';
Exec('cmd.exe', '/c ipconfig /all >"' + ExpandConstant('{tmp}\adapter.info') + '"', '', SW_HIDE,
ewWaitUntilTerminated, ResultCode);
LoadStringsFromFile(ExpandConstant('{tmp}\adapter.info'), strArray);
for i := 0 to GetArrayLength(strArray)-1 do
if Length(strArray[i]) > 16 then
begin
strArray[i] := DosToAnsi(strArray[i]);
strLen := Length(strArray[i]);
MsgBox(strArray[i], mbInformation, MB_OK);
if (CompareStr('-', strArray[i][strLen-2] ) = 0) and
(CompareStr('-', strArray[i][strLen-5] ) = 0) and
(CompareStr('-', strArray[i][strLen-8] ) = 0) and
(CompareStr('-', strArray[i][strLen-11]) = 0) and
(CompareStr('-', strArray[i][strLen-14]) = 0) and
(Pos('VMware', strArray[i]) = 0) and
(Pos('Hamachi', strArray[i]) = 0) then
Result := Result + #10#13 + Copy(strArray[i], strLen-16, 17);
end;
end;