Go Back   FileForums > Game Backup > PC Games > PC Games - CD/DVD Conversions > Conversion Tutorials

Reply
 
Thread Tools Display Modes
  #1  
Old 11-04-2014, 05:57
peterf1999's Avatar
peterf1999 peterf1999 is offline
Die Hard Member
 
Join Date: Nov 2008
Location: Italy
Posts: 928
Thanks: 14
Thanked 982 Times in 236 Posts
peterf1999 is on a distinguished road
Useful Dll for Inno Setup users

So far I used a crap dll (get_hw_caps.dll) for hardware detection in Inno's script,
so I decided to make a own dll to solve this problem.

At this time the dll exports several Functions/Procedures,
of which the most useful for forum users are:


Prototype:
procedure GetSysInfo(var SysInfo: TSysInfo);

Description:
Returns extended information about the computer system as record through WMI interface:

Code:
Type
 TSysInfo = record
 ProcessorName: PAnsiChar;
 MaxClockSpeed, CurrentClockSpeed: integer; { Returns the number of MHZ } 
 Manufacturer: PAnsiChar;
 NumberofPhysicalCores,NumberOfLogicalProcessors: integer;
 VgaAdapterName: PAnsiChar;
 VgaAdapterRam,CurrentHorizontalResolution,CurrentVerticalResolution,CurrentRefreshRate: integer; { VgaAdapterRam: returns the number of megabytes } 
 VideoModeDescription,AudioDeviceName: PAnsiChar;
 TotalVisibleMemorySize,FreePhysicalMemory: integer; { Returns the number of megabytes } 
 OSName: PAnsiChar;
 OSVersionMajor,OSVersionMinor,OSBuildNumbers: Cardinal;
 ServicePackMajorVersion,ServicePackMinorVersion: Word;
 OSArchitecture: Byte; { On windows Xp returns 0, this property is not available } 
 end;
Inno Setup prototype declaration:

procedure GetSysInfo(var SysInfo: TSysInfo);
external 'GetSysInfo@files:Isab.dll stdcall delayload';

var SystemInfo: TSysInfo;

GetSysInfo(SystemInfo);

sysinfo.jpg


Prototype:
procedure CreateTaskBarProgress(hWnd :longword);

Description:
Create progress indicators with notification and status overlays on application's taskbar button.

Inno Setup prototype declaration:

procedure CreateTaskBarProgress(hWnd :longword);
external 'CreateTaskBarProgress@files:Isab.dll stdcall delayload';

hWnd: Handle of window's owner window

Requirements: Windows 7 or later OS.

const
GW_OWNER = 4;

CreateTaskBarProgress(GetWindow(MainForm.Handle,GW _OWNER)); { Retrieve the application's handle and then creates progress taskbar button }



Prototype:
procedure TaskBarSetProgress(Completed, Total: integer);

Description:
Displays a taskbar button to show the specific percentage completed of the full operation.

Inno Setup prototype declaration:

procedure TaskBarSetProgress(Completed, Total: integer);
external 'TaskBarSetProgress@files:Isab.dll stdcall delayload';

Completed: An integer value that indicates the proportion of the operation that has been completed at the time.

Total: An integer value that specifies the value 'Total' will have when the operation is complete.

Requirements: Windows 7 or later OS.


Prototype:
procedure TaskBarSetState(tbpFlags: integer);

Description:
Sets the type and state of the progress indicator displayed on a taskbar button.

const
TBPF_NOPROGRESS = 0;
TBPF_INDETERMINATE = 1;
TBPF_NORMAL = 2;
TBPF_ERROR = 4;
TBPF_PAUSED = 8;

Inno Setup prototype declaration:

procedure TaskBarSetState(tbpFlags: integer);
external 'TaskBarSetState@files:Isab.dll stdcall delayload';

tbpFlags: Flags that control the current state of the application's progress taskbar button.

Requirements: Windows 7 or later OS.

TaskBarSetState(TBPF_INDETERMINATE);



Prototype:
procedure ReleaseTaskBarProgress;

Description:
Release the application's progress taskbar button after usage.

Inno Setup prototype declaration:

procedure ReleaseTaskBarProgress;
external 'ReleaseTaskBarProgress@files:Isab.dll stdcall delayload';

Requirements: Windows 7 or later OS.

Status overlays of Inno Setup's taskbar progress button during Freearc's archives files extraction:

TaskBarProgress.jpg



Prototype:
function CheckFileSHA1(Filename,HashHex: PAnsichar; PctOfTotal: integer; callback: THashProgress): integer;

Description:
Checks the file integrity through its given SHA-1 hash value, returns 0 if the function was called successfully, otherwise the following values are returned:

-1: Check of installation file has been interrupted.

-2: File hash does not match.

-3: Source File not found.


Callback function declaration:

Type
THashProgress = function(OverallProgress,FileProgress: Integer): Boolean;


Inno Setup prototype declaration:

function CheckFileSHA1(fileName,HashHex : PAnsichar; PctOfTotal: integer; callback: THashProgress ): integer;
external 'CheckFileSHA1@files:Isab.dll stdcall delayload';

Filename: file name of which you need to check its integrity through the source hash value
HashHex: SHA-1 hash value in hexadecimal number representation (40 digits long)
PctOfTotal: percentage of total files size (for 1 file the value is 100)
callback: address of callback function that returns boolean values and the OverallProgress & FileProgress values from main function

Callback function values:

OverallProgress: 1000 is the max value returned
FileProgress: 1000 is the max value returned

Code:
e.g. Callback function:

function Sha1Progress(OverallProgress,FileProgress: Integer): Boolean;

Begin
... {Update progress bar status of overall progress } 
... {Update progress bar status of file progress } 
result:=not CancelButton { returns true/false values, useful to continue (true) or abort(false) operation if cancel button (global variable assigned) on custom form with progress bars is pressed  } 
end;

function InitializeSetup(): Boolean;
var ReturnCode: integer;

begin
    ... {Create custom form with progress bars and cancel button } 
    Result:=True;
    try
      repeat
    
       ReturnCode:=CheckFileSHA1(ExpandConstant('{src}\Data1.bin'),'5C5DD1032773DAB058656F7E7168788DD9138288',60,@Sha1Progress);
       if  ReturnCode <> 0 then break;
       ReturnCode:=CheckFileSHA1(ExpandConstant('{src}\Data2.bin'),'FCA8E69C00CA0E0D5FB5C8E48B07A92F9C7DC5BA',40,@Sha1Progress);
       if  ReturnCode <> 0 then break; 
     
     until true
    
   finally
      case ReturnCode of
     -1: begin
           MsgBox('Check of installation files has been interrupted!', mbCriticalError, mb_Ok);
           Result:=false;
        end;
    -2: begin
           MsgBox('File hash does not match, installation aborted!',mbCriticalError, mb_Ok);
           Result:=false;
      end;
    -3: begin
           MsgBox('File not found!',mbCriticalError, mb_Ok);
           Result:=false;
      end;
    end;
    
    end;
end;


Prototype:
function GetFileSHA1(Filename: PAnsichar): PAnsiChar;

Description:
Gets the SHA-1 hash in hexadecimal number representation (40 digits long) of the specified file.
An exception will be raised upon failure.

Inno Setup prototype declaration:

function GetFileSHA1(fileName: PAnsichar): PAnsiChar;
external 'GetFileSHA1@files:Isab.dll stdcall delayload';

Filename: file name of which you get hash hex string value



Prototype:
function JoinFile(FirstSourceFile,TargetFile: PAnsichar; DeleteSourceFiles: Boolean; callback: TJoinProgress): integer;

Description:
Joins splitted file parts to the specified target file, returns 0 if the function was called successfully, otherwise the return value is nonzero.

Callback procedure declaration:

Type
TJoinProgress = procedure(CurrentFilenamePart:PAnsiChar;TotalFiles PartSize,OverallProgress: Integer);

Inno Setup prototype declaration:

function JoinFile(FirstSourceFile,TargetFile: PAnsichar; DeleteSourceFiles: Boolean; callback: TJoinProgress): integer;
external 'JoinFile@files:Isab.dll stdcall delayload';

FirstSourceFile: file name of 1st part, its extension must be *.part1, for others file parts *.part2, *.part3 ...and so on.
TargetFile: target file name of the joining operation.
DeleteSourceFiles: if set to true the file parts will be deleted after successfully joining operation.
callback: address of callback procedure that returns CurrentFilenamePart, TotalFilesPartSize, OverallProgress values from main function.

Callback procedure values:

CurrentFilenamePart: name of the file part that is being joined to target file
TotalFilesPartSize: total files size of splitted parts expressed in Megabytes
OverallProgress: 1000 is the max value returned

Code:
e.g.:

type
TJoinProgress = procedure(CurrentFilenamePart:PAnsiChar;TotalFilesPartSize,OverallProgress: Integer);

procedure JoinProgress(CurrentFilenamePart: PAnsiChar; TotalFilesPartSize,OverallProgress: Integer);
begin
...
...
end;

JoinFile(ExpandConstant('{app}\Myfile.part1'),ExpandConstant('{app}\MyTargetfile.bin'),True,@JoinProgress);


Prototype:
function GetFileSize(FileName: PAnsichar): Extended;

Description:
Returns the size of the specified file in bytes as extented type.
If the function fails, the return value is -1.

Inno Setup prototype declaration:

function GetFileSize(FileName: PAnsichar): Extended;
external 'GetFileSize@files:Isab.dll stdcall delayload';

Filename: file name of which you get the size



Prototype:
function GetFileSize64(FileName: AnsiString): Int64;

Description:
Returns the size of the specified file in bytes as 64 bit integer type.
If the function fails, the return value is -1.

Inno Setup prototype declaration:

function GetFileSize64(const FileName: AnsiString): Int64;
external 'GetFileSize64@files:Isab.dll stdcall delayload';

Filename: file name of which you get the size

Requirements: Inno Setup Unicode v5.5.3 or later.



Prototype:
function LoadFileToBuffer(FileName: PAnsichar): PAnsiChar;

Description:
Loads file contents to memory buffer and returns the pointer to null-terminated Ansistring,
If the function fails, the return value is a null string.

Inno Setup prototype declaration:

function LoadFileToBuffer(FileName: PAnsichar): PAnsiChar;
external 'LoadFileToBuffer@files:Isab.dll stdcall delayload';

Filename: file name whose content will be loaded into memory buffer



Prototype:
function EncryptStr(StringtoEncrypt,Passphrase: PAnsichar): PAnsiChar;

Description:
Encrypts the given string with 256 bits key AES cipher.

Inno Setup prototype declaration:

function EncryptStr(StringtoEncrypt,Passphrase: PAnsichar): PAnsiChar;
external 'EncryptStr@files:Isab.dll stdcall delayload';

StringtoEncrypt: String to encrypt with Advanced Encryption Standard (AES)
Passphrase: Password used as an encryption key



Prototype:
function DecryptStr(StringtoDecrypt,Passphrase: PAnsichar): PAnsiChar;

Description:
Restores original string value encrypted with AES cipher.

Inno Setup prototype declaration:

function DecryptStr(StringtoDecrypt,Passphrase: PAnsichar): PAnsiChar;
external 'DecryptStr@files:Isab.dll stdcall delayload';

StringtoDecrypt: String to decrypt from Advanced Encryption Standard (AES)
Passphrase: Password used as an encryption key



Prototype:
SaveFileFromBuffer(Buffer: PAnsichar; const OutFileName: PAnsichar): integer;

Description:
Saves memory buffer contents to specified file, if the function fails, the return value is nonzero.

Inno Setup prototype declaration:

function SaveFileFromBuffer(Buffer: PAnsichar; const OutFileName: PAnsichar): integer;
external 'SaveFileFromBuffer@files:Isab.dll' stdcall delayload';

Buffer: pointer to a memory location that contains the file's content
Filename: name of the file that will be created from memory buffer


Prototype:
function DiskVolumeInfo(RootDir: PAnsichar; var Volume: TVolume; const OutTypeFlags: Byte): Boolean;

const
TF_InBytes = 1;
TF_InKiloBytes = 2;
TF_InMegaBytes = 4;
TF_InGigaBytes = 8;

type
TVolume = record
VolumeName,FileSystemName: PAnsiChar;
VolFreeSpace,VolSize: Double;
end;

Var
Volume: TVolume;

Description:
Retrieves information about the file system, the amount of free space and total size, and volume name associated with the specified root directory.
Returns True if the function was called successfully, False otherwise.

Inno Setup prototype declaration:

function DiskVolumeInfo(RootDir: PAnsichar; var Volume: TVolume; const OutTypeFlags: Byte): Boolean;
external 'DiskVolumeInfo@files:Isab.dll stdcall delayload';

RootDir: Root directory of the volume with an appended trailing backslash. e.g.(C:\)
Volume: Declared variable to create an instance of TVolume record
OutTypeFlags: Flags that control the output type of the amount of free space and total size (TF_InBytes = 1 returns the values expressed in bytes, TF_InKiloBytes = 2 ... and so on...)



Prototype:
function GetFixedDrives: PAnsichar;

Description:
Retrieves the root dirs of the drives that have fixed media: a hard disk drive, flash drive or SSD and
then store them into null-terminated ansistring.
Each root dirs found are separated by carriage return and line feed char(#13), char(#10).

Inno Setup prototype declaration:

function GetFixedDrives: PAnsichar;
external 'GetFixedDrives@files:Isab.dll stdcall delayload';

the function has no input parameters

GetFixedDrives & DiskVolumeInfo functions usage example:

Code:
#define SourcePath ""

[Setup]
AppName={#GetStringFileInfo(SourcePath+'Isab.dll',PRODUCT_NAME)}
AppVersion={#GetStringFileInfo(SourcePath+'Isab.dll',FILE_VERSION)}
DefaultDirName={pf}\{#GetStringFileInfo(SourcePath+'Isab.dll',FILE_DESCRIPTION)}

[Files]

Source: Isab.dll; DestDir: {tmp}; Flags: dontcopy


const
  TF_InBytes = 1;
  TF_InKiloBytes = 2;
  TF_InMegaBytes = 4;
  TF_InGigaBytes = 8;

type
  TVolume = record
  VolumeName,FileSystemName: PAnsiChar;
  VolFreeSpace,VolSize: Double;
 end;

function DiskVolumeInfo(RootDir: PAnsichar; var Volume: TVolume; const OutTypeFlags: Byte): Boolean; external 'DiskVolumeInfo@files:Isab.dll stdcall delayload';
function GetFixedDrives: PAnsichar; external 'GetFixedDrives@files:Isab.dll stdcall delayload';


function InitializeSetup(): Boolean;
var c: integer;
    outstr: ansistring;
    drives_list: Pansichar;
    Volume: TVolume;
    str_Letters: TStringlist;

begin
   Result:=true;
   str_letters:=TStringlist.Create;
   drives_list:=GetFixedDrives;
   str_letters.text:=drives_list;
    for c:= 0 to str_letters.Count -1 do begin
       if DiskVolumeInfo(str_letters.strings[c],Volume, TF_InBytes) then
       outstr:=outstr+'Drive: '+str_letters.strings[c]+#13#10+'Label: '+volume.VolumeName+#13#10+
       'FileSystem: '+volume.FileSystemName+#13#10+'Size: '+format('%.0n',[volume.VolSize])+#13#10+
       'FreeSpace: '+format('%.0n',[volume.Volfreespace])+#13#10#13#10;
    end;
   msgbox(outstr,mbInformation, mb_Ok);
end;

Prototype:
function CheckDiskLabel(RootDir: PAnsichar; const LabelName: PAnsichar): Boolean;

Description:
Checks if the LabelName matches the volume label of the physical media (CD-ROM, DVD...) to verify that the proper disk is in the drive.
If the disk label matches, the return value is True, False otherwise.

Inno Setup prototype declaration:

function CheckDiskLabel(RootDir: PAnsichar; const LabelName: PAnsichar): Boolean;
external 'CheckDiskLabel@files:Isab.dll stdcall delayload';

RootDir: Root directory of the drive with an appended trailing backslash
LabelName: label name of the physical media to check

Code:
if CheckDiskLabel(ExpandConstant('{src}\'),'DISK_1') then

// the disk label matches, installation can continue... 

else 

// handle the wrong disk status
Note: The function ignores the uppercase text of the label : DISK_1 is equal to disk_1 or Disk_1


Prototype:
function CreateTimer(Timeout: Longword; callback: TTimerProc): Longword;

Description:
Creates a timer with the specified time-out value, the return value is an identifier of timer event.

Callback procedure declaration:

Type
TTimerProc= procedure(Hwnd,Msg,Idevent,DwTime: Longword);

Inno Setup prototype declaration:

function CreateTimer(Timeout: Longword; callback: TTimerProc): Longword;
external 'CreateTimer@files:Isab.dll stdcall delayload';

Timeout: Time-out interval expressed in milliseconds
callback: address of callback procedure called when the time-out value elapses


Prototype:
procedure DestroyTimer(IdEvent: Longword);

Description:
Destroys the specified timer.

Inno Setup prototype declaration:

procedure DestroyTimer(IdEvent: Longword);
external 'DestroyTimer@files:Isab.dll stdcall delayload';

IdEvent: identifier of timer event returned from CreateTimer

CreateTimer & DestroyTimer usage example:

Code:
#define SourcePath ""

[Setup]
AppName={#GetStringFileInfo(SourcePath+'Isab.dll',PRODUCT_NAME)}
AppVersion={#GetStringFileInfo(SourcePath+'Isab.dll',FILE_VERSION)}
DefaultDirName={pf}\{#GetStringFileInfo(SourcePath+'Isab.dll',FILE_DESCRIPTION)}

[Files]

Source: Isab.dll; DestDir: {tmp}; Flags: dontcopy


type
   TTimerProc= procedure(Hwnd,Msg,Idevent,DwTime: Longword);

var
   IdEvent: Longword;

function CreateTimer(Timeout: Longword; callback: TTimerProc): Longword; external 'CreateTimer@files:Isab.dll stdcall delayload';
procedure DestroyTimer(IdEvent: Longword); external 'DestroyTimer@files:Isab.dll stdcall delayload';

procedure TimerProc(Hwnd,Msg,Idevent,DwTime: Longword);
begin
  PageFromId(wpWelcome).Surface.Color:=Random($FFFFFF);
end;

function InitializeSetup(): Boolean;
begin
  Result:=true;
  IdEvent:=CreateTimer(1000,@TimerProc);
end;

Procedure DeInitializeSetup;
Begin
  DestroyTimer(IdEvent);
end;

Prototype:
function TicksToTime(Ticks: Cardinal): PAnsiChar;

Description:
Converts milliseconds to human readable format (Hours:Minutes:Seconds).

Inno Setup prototype declaration:

function TicksToTime(Ticks: Cardinal): PAnsiChar;
external 'TicksToTime@files:Isab.dll stdcall delayload';

Ticks: number of ticks to be converted


Prototype:
procedure StartWatch(callback: TSTime);

Description:
Starts watch to measure elapsed time in human readable format.

Callback procedure declaration:

Type
TSTime= procedure(Hours,Minutes,Seconds: integer; TicksElapsed: Cardinal);

Inno Setup prototype declaration:

procedure StartWatch(callback: TSTime);
external 'StartWatch@files:Isab.dll stdcall delayload';

callback: address of callback procedure that returns Hours, Minutes, Seconds, TicksElapsed values

Callback procedure values:

Hours: Hours elapsed
Minutes: Minutes elapsed
Seconds: Seconds elapsed
TicksElapsed: Total time elapsed expressed in Milliseconds


Prototype:
procedure StopWatch;

Description:
Stops watch and kills the callback fired by StartWatch

Inno Setup prototype declaration:

procedure StopWatch;
external 'StopWatch@files:Isab.dll stdcall delayload';


Prototype:
procedure ResetWatch;

Description:
Resets watch to origin time state (0h:0m:0s)

Inno Setup prototype declaration:

procedure ResetWatch;
external 'ResetWatch@files:Isab.dll stdcall delayload';

StartWatch, StopWatch, ResetWatch & TicksToTime usage example:
Code:
#define SourcePath ""

[Setup]
AppName={#GetStringFileInfo(SourcePath+'Isab.dll',PRODUCT_NAME)}
AppVersion={#GetStringFileInfo(SourcePath+'Isab.dll',FILE_VERSION)}
DefaultDirName={pf}\{#GetStringFileInfo(SourcePath+'Isab.dll',FILE_DESCRIPTION)}

[Files]

Source: Isab.dll; DestDir: {tmp}; Flags: dontcopy


type
  TSTime= procedure(Hours,Minutes,Seconds: integer; TicksElapsed: Cardinal);

var
  LTime: Tlabel;

procedure StartWatch(callback: TSTime); external 'StartWatch@files:Isab.dll stdcall delayload';
procedure StopWatch; external 'StopWatch@files:Isab.dll stdcall delayload';
procedure ResetWatch; external 'ResetWatch@files:Isab.dll stdcall delayload';
function TicksToTime(Ticks: Cardinal): PAnsiChar; external 'TicksToTime@files:Isab.dll stdcall delayload';


procedure ElpsTime(Hours,Minutes,Seconds: integer; TicksElapsed: Cardinal);
begin
LTime.Caption:=TicksToTime(TicksElapsed);
WizardForm.Caption:=inttostr(Hours)+' hours: '+inttostr(Minutes)+' minutes: '+inttostr(Seconds)+' seconds';
end;

procedure StartWatchBtnOnClick(Sender: TObject);
begin
StartWatch(@ElpsTime);
end;

procedure StopWatchBtnOnClick(Sender: TObject);
begin
StopWatch;
end;

procedure ResetWatchBtnOnClick(Sender: TObject);
begin
ResetWatch;
end;

function InitializeSetup(): Boolean;
begin
  Result:=true;
end;

procedure InitializeWizard();
var
  StartWatchBtn, StopWatchBtn, CancelButton, ResetWatchBtn: TButton;
  
  begin
  CancelButton := WizardForm.CancelButton;
 
  StartWatchBtn:= TButton.Create(WizardForm);
  StartWatchBtn.Left := ScaleX(5);
  StartWatchBtn.Top := CancelButton.Top;
  StartWatchBtn.Width := ScaleX(80);
  StartWatchBtn.Height := CancelButton.Height;
  StartWatchBtn.Caption := '&StartWatch';
  StartWatchBtn.OnClick := @StartWatchBtnOnClick;
  StartWatchBtn.Parent := WizardForm;

  StopWatchBtn := TButton.Create(WizardForm);
  StopWatchBtn.Left := ScaleX(90);
  StopWatchBtn.Top := CancelButton.Top;
  StopWatchBtn.Width := ScaleX(80);
  StopWatchBtn.Height := CancelButton.Height;
  StopWatchBtn.Caption := 'S&topWatch';
  StopWatchBtn.OnClick := @StopWatchBtnOnClick;
  StopWatchBtn.Parent := WizardForm;

  ResetWatchBtn := TButton.Create(WizardForm);
  ResetWatchBtn.Left := ScaleX(175);
  ResetWatchBtn.Top := CancelButton.Top;
  ResetWatchBtn.Width := ScaleX(80);
  ResetWatchBtn.Height := CancelButton.Height;
  ResetWatchBtn.Caption := '&ResetWatch';
  ResetWatchBtn.OnClick := @ResetWatchBtnOnClick;
  ResetWatchBtn.Parent := WizardForm;

  LTime := TLabel.Create(WizardForm);
  LTime.AutoSize  := False;
  LTime.Font.Size:=35;
  LTime.Font.Name:='courier new';
  LTime.Width := ScaleX(WizardForm.WelcomeLabel2.Width);
  LTime.Height:=55;
  LTime.Left := ScaleX(0);
  LTime.Top := ScaleY(WizardForm.WelcomeLabel2.Height div 2);
  LTime.Caption := '';
  LTime.Alignment:=taCenter;
  LTime.Parent := WizardForm.WelcomeLabel2;
  LTime.Transparent:=True;
 end;
Prototype:
function PosReverse(const SubStr,Str: PAnsiChar): Integer;

Description:
Searches for Substr within Str in reverse order and returns an integer value that is the index of the first character of Substr within Str.
If Substr is not found, the return value is zero.

Inno Setup prototype declaration:

function PosReverse(const SubStr,Str: PAnsiChar): Integer;
external 'PosReverse@files:Isab.dll stdcall delayload';

Substr: substring to search for
Str: main string


Prototype:
function CreateRgnFromBmp(hWnd :HWND; const BmpFileName: PAnsiChar; TrRGBColor: integer): integer;

Description:
Creates a shaped window region using a bitmap image file as alpha mask.
The function scans a bitmap image data, skip over the transparent pixels, and create the shaped region with non-transparent pixels.
if the function fails, the return value is nonzero.

Inno Setup prototype declaration:

function CreateRgnFromBmp(hWnd :HWND; const BmpFileName: PAnsiChar; TrRGBColor: integer): integer;
external 'CreateRgnFromBmp@files:Isab.dll stdcall delayload';

hWnd: a handle of the window whose region is to be shaped
BmpFileName: filename of bitmap image
TrRGBColor: red, green, blue color component values in hexadecimal number representation of bitmap transparent color


Prototype:
function CreateFormFromBmp(hWnd :HWND; const BmpFilename: PAnsiChar; ACPremultiplied: Boolean ): Integer;

Description:
Creates alpha blended form from a 32-bit RGBA (Red Green Blue Alpha) bitmap.
if the function fails, the return value is nonzero.

Inno Setup prototype declaration:

function CreateFormFromBmp(hWnd: HWND; const BmpFilename: PAnsiChar; ACPremultiplied: Boolean): Integer;
external 'CreateFormFromBmp@files:Isab.dll stdcall delayload';

hWnd: a handle of the window is to be alpha-blended
BmpFilename: filename of bitmap image
ACPremultiplied: If the bitmap has Premultiplied Alpha ( Red, Blue and Green color channels have already been multiplied with the Alpha channel and the transparency information is already stored) set it to true
Code:
#define SourcePath ""

[Setup]
AppName={#GetStringFileInfo(SourcePath+'Isab.dll',PRODUCT_NAME)}
AppVersion={#GetStringFileInfo(SourcePath+'Isab.dll',FILE_VERSION)}
DefaultDirName={pf}\{#GetStringFileInfo(SourcePath+'Isab.dll',FILE_DESCRIPTION)}

[Files]

Source: Isab.dll; DestDir: {tmp}; Flags: dontcopy
Source: Wizard_Res\AlphaMask.bmp; DestDir: {tmp}; Flags: dontcopy
Source: Wizard_Res\BmpForm.bmp; DestDir: {tmp}; Flags: dontcopy

var
   RegionBmp: TBitmapImage;
   AForm: TForm;

function CreateRgnFromBmp(WndH :HWND; const BmpFileName: PAnsiChar; TrRGBColor: integer): integer; external 'CreateRgnFromBmp@files:Isab.dll stdcall delayload';
function CreateFormFromBmp(WndH :HWND; const BmpFilename: PAnsiChar; ACPremultiplied: Boolean ): Integer; external 'CreateFormFromBmp@files:Isab.dll stdcall delayload';


function InitializeSetup(): Boolean;
begin
  Result:=true;
end;

procedure InitializeWizard();
begin

    ExtractTemporaryFile('AlphaMask.bmp');
    ExtractTemporaryFile('BmpForm.bmp');

    WizardForm.Innernotebook.hide;
    WizardForm.Outernotebook.hide;
    WizardForm.Height:=405;
    WizardForm.Width:=593;
    WizardForm.BorderStyle := bsNone;
    WizardForm.Position := poScreenCenter;

AForm:=TForm.Create(nil);
 With AForm do begin
    Height:=WizardForm.Height;
    Width:=WizardForm.Width;
    Position := poScreenCenter;
    BorderStyle:=bsnone;
 end;
  
RegionBmp:=TBitmapimage.Create(nil);
 With RegionBmp Do Begin
    parent:=WizardForm;
    Height:=WizardForm.Height;
    Width:=WizardForm.width;
 end;
 
  CreateRgnFromBmp(WizardForm.Handle,ExpandConstant('{tmp}\AlphaMask.bmp'),$000000);
  RegionBmp.Bitmap.LoadFromFile(ExpandConstant('{tmp}\BmpForm.bmp'));
  CreateFormFromBmp(AForm.Handle,ExpandConstant('{tmp}\BmpForm.bmp'),true);
  AForm.Show;
end;

Prototype:
function GetFileVersionData(Const FileName: String; Const FlgRes: integer): String; =>(UNICODE)
function GetFileVersionData(Const FileName: PAnsiChar; Const FlgRes: integer): PAnsiChar; =>(ANSI)

Description:
Retrieves version information for a specified file (exe,dll...) from its resource.
An exception will be raised upon failure.

const
RESF_CompanyName = 1;
RESF_FileDescription = 2;
RESF_FileVersion = 3;
RESF_InternalName = 4;
RESF_LegalCopyright = 5;
RESF_LegalTrademarks = 6;
RESF_OriginalFileName = 7;
RESF_ProductName = 8;
RESF_ProductVersion = 9;
RESF_Comments = 10;
RESF_PrivateBuild = 11;
RESF_SpecialBuild = 12;

Inno Setup prototype declaration (respectively, UNICODE and ANSI):

function GetFileVersionData(Const FileName: String; Const FlgRes: integer): String;
external 'GetFileVersionDataW@files:Isab.dll stdcall delayload';

function GetFileVersionData(Const FileName: PAnsiChar; Const FlgRes: integer): PAnsiChar;
external 'GetFileVersionDataA@files:Isab.dll stdcall delayload';

FileName: filename which contains a version-information resource to retrieve
FlgRes: Flags to retrieve the specified file resource

Code:
#define SourcePath ""

[Setup]
AppName={#GetStringFileInfo(SourcePath+'Isab.dll',PRODUCT_NAME)}
AppVersion={#GetStringFileInfo(SourcePath+'Isab.dll',FILE_VERSION)}
DefaultDirName={pf}\{#GetStringFileInfo(SourcePath+'Isab.dll',FILE_DESCRIPTION)}

[Files]

Source: Isab.dll; DestDir: {tmp}; Flags: dontcopy

const
  RESF_CompanyName = 1;
  RESF_FileDescription = 2;
  RESF_FileVersion = 3;
  RESF_InternalName = 4;
  RESF_LegalCopyright = 5;
  RESF_LegalTrademarks = 6;
  RESF_OriginalFileName = 7;
  RESF_ProductName = 8;
  RESF_ProductVersion = 9;
  RESF_Comments = 10;
  RESF_PrivateBuild = 11;
  RESF_SpecialBuild = 12;

#ifdef UNICODE
function GetFileVersionData(Const FileName: String; Const FlgRes: integer): String;
external 'GetFileVersionDataW@files:Isab.dll stdcall delayload';
#else
function GetFileVersionData(Const FileName: PAnsiChar; Const FlgRes: integer): PAnsiChar;
external 'GetFileVersionDataA@files:Isab.dll stdcall delayload';
#endif


function InitializeSetup(): Boolean;

begin
  Result:=True;
  try
     MsgBox(GetFileVersionData(ExpandConstant('{win}\Notepad.exe'),RESF_FileDescription), mbInformation, MB_OK);
   except
     MsgBox('GetFileVersionData exception!', mbCriticalError, MB_OK);
     Result:=False;
  end;
end;
Prototype:
procedure GdiStartup;

Description:
Initializes Microsoft Windows GDI+ class-based API.

Inno Setup prototype declaration:

procedure GdiStartup;
external 'GdiStartup@files:Isab.dll stdcall delayload';

Prototype:
procedure GdiShutdown;

Description:
Cleans up resources used by GDI+ API.

Inno Setup prototype declaration:

procedure GdiShutdown;
external 'GdiShutdown@files:Isab.dll stdcall delayload';


Prototype:
function LoadImage(const FileName: PAnsiChar; Handle: HWND; X,Y,Height,Width: integer; const IMF_Img: byte): integer;

Description:
Loads the raster image and then creates image object.
Returns image-index if the function was called successfully, zero otherwise.

const
IMF_Scale = 1;
IMF_Crop = 2;


Inno Setup prototype declaration:

function LoadImage(const FileName: PAnsiChar; Handle: HWND; X,Y,Height,Width: integer; const IMF_Img: byte): integer;
external 'LoadImage@files:Isab.dll stdcall delayload';

FileName: file name of raster image to load
Handle: Handle of device context
X: X position of the rectangle's upper-left corner
Y: Y position of the rectangle's upper-left corner
Height: Height of image expressed in pixels
Width: Width of image expressed in pixels
IMF_Img: flags for cropping\scaling the image


Prototype:
procedure DrawImages(Handle: HWND);

Description:
Draws image(s) to specified device context.

Inno Setup prototype declaration:

procedure DrawImages(Handle: HWND);
external 'DrawImages@files:Isab.dll stdcall delayload';

Handle: Handle of device context


Prototype:
procedure SetImgVisibility(ImgIdx: Integer; Visibility: Boolean);

Description:
Shows or hides image from specified index given.

Inno Setup prototype declaration:

procedure SetImgVisibility(ImgIdx: Integer; Visibility: Boolean);
external 'SetImgVisibility@files:Isab.dll stdcall delayload';

ImgIdx: Index of loaded image returned from LoadImage function
Visibility: Image visibility (True=visible or False=hidden)


Prototype:
procedure SetImgTransparency(ImgIdx: Integer; ImgTransparency: Byte);

Description:
Defines and sets the amount of image's transparency.
The range's value of transparency effect is 0 to 100 (0=fully opaque, 100=fully transparent).

Inno Setup prototype declaration:

procedure SetImgTransparency(ImgIdx: Integer; ImgTransparency: Byte);
external 'SetImgTransparency@files:Isab.dll stdcall delayload';

ImgIdx: Index of image returned from LoadImage function
ImgTransparency: transparency range's value (0-100)


Prototype:
function GetImgVisibility(ImgIdx: Integer): Boolean;

Description:
Checks if the image is visible or not.
Returns True whether the content of the image is visible, otherwise false.

Inno Setup prototype declaration:

function GetImgVisibility(ImgIdx: Integer): Boolean;
external 'GetImgVisibility@files:Isab.dll stdcall delayload';

ImgIdx: Index of image returned from LoadImage function


Prototype:
function GetImgTransparency(ImgIdx: Integer): Byte;

Description:
Retrieves image transparency range's value (0-100).

Inno Setup prototype declaration:

function GetImgTransparency(ImgIdx: Integer): Byte;
external 'GetImgTransparency@files:Isab.dll stdcall delayload';

ImgIdx: Index of image returned from LoadImage function


Prototype:
procedure SetImgPosSize(ImgIdx,X,Y,Height,Width: integer);

Description:
Sets position and size of the image relative to the client area.

Inno Setup prototype declaration:

procedure SetImgPosSize(ImgIdx,X,Y,Height,Width: integer);
external 'SetImgPosSize@files:Isab.dll stdcall delayload';

ImgIdx: Index of image returned from LoadImage function
X: X position of the rectangle's upper-left corner
Y: Y position of the rectangle's upper-left corner
Height: Height of image expressed in pixels
Width: Width of image expressed in pixels


Prototype:
procedure GetImgPosSize(ImgIdx: integer; var X,Y,Height,Width: integer);

Description:
Retrieves position and size of the image relative to the client area.

Inno Setup prototype declaration:

procedure GetImgPosSize(ImgIdx: integer; var X,Y,Height,Width: integer);
external 'GetImgPosSize@files:Isab.dll stdcall delayload';

ImgIdx: Index of image returned from LoadImage function
X: Declared variable as parameter relative to X position of the rectangle's upper-left corner
Y: Declared variable as parameter relative to Y position of the rectangle's upper-left corner
Height: Declared variable as parameter relative to Height of image expressed in pixels
Width: Declared variable as parameter relative to Width of image expressed in pixels


Prototype:
procedure RotateImg(ImgIdx,Rangle: integer);

Description:
Rotates image by specified angle around its center. Positive angle values specify clockwise rotation.

Inno Setup prototype declaration:

procedure RotateImg(ImgIdx,Rangle: integer);
external 'RotateImg@files:Isab.dll stdcall delayload';

ImgIdx: Index of image returned from LoadImage function
Rangle: angle of rotation expressed in sexagesimal degrees


Prototype:
procedure SetVisibleImgRgn(ImgIdx,LeftOffset,TopOffset,Visib leRgnHeight,VisibleRgnWidth: integer);

Description:
Sets and draws a portion of image loaded.

Inno Setup prototype declaration:

procedure SetVisibleImgRgn(ImgIdx,LeftOffset,TopOffset,Visib leRgnHeight,VisibleRgnWidth: integer);
external 'SetVisibleImgRgn@files:Isab.dll stdcall delayload';

ImgIdx: Index of image returned from LoadImage function
LeftOffset: Offset relative to X axis of native position
TopOffset: Offset relative to Y axis of native position
VisibleRgnHeight: Height of image's region that will be visible
VisibleRgnWidth: Width of image's region that will be visible
Attached Files
File Type: 7z ISab.dll.7z (625.4 KB, 505 views)

Last edited by peterf1999; 05-05-2016 at 01:56.
Reply With Quote
The Following 39 Users Say Thank You to peterf1999 For This Useful Post:
-XCX- (01-02-2017), 4tRUst (27-10-2015), 78372 (06-07-2017), Abbat (12-05-2019), ADMIRAL (21-02-2020), ALiAS2015 (17-06-2015), altef_4 (11-04-2014), Andrey167 (12-12-2014), arkantos7 (04-05-2014), BAMsE (23-03-2016), Breakerways (19-04-2017), Carldric Clement (12-12-2014), ChronoCross (12-12-2014), COPyCAT (22-04-2016), EyeSalt (02-03-2018), Fahimft2014 (09-11-2014), ffmla (27-08-2016), gozarck (19-03-2015), Grumpy (11-04-2014), GTX590 (16-02-2016), Gupta (18-02-2017), hpmbot149 (07-06-2016), Ichiraku2001 (03-04-2016), JRD! (14-01-2016), Lucas65 (12-03-2016), mausschieber (12-04-2014), Nemko (11-08-2017), NickX700K (10-08-2019), oltjon (03-01-2017), pakrat2k2 (17-04-2014), pebe (05-04-2015), PsYcHo_RaGE (27-05-2018), RamiroCruzo (26-10-2015), Razor12911 (13-04-2014), sakila(playboy) (08-10-2022), saradaddy (10-02-2016), Simorq (25-01-2015), Sony091090 (04-10-2016), y_thelastknight (11-04-2014)
Sponsored Links
  #2  
Old 12-04-2014, 12:13
peterf1999's Avatar
peterf1999 peterf1999 is offline
Die Hard Member
 
Join Date: Nov 2008
Location: Italy
Posts: 928
Thanks: 14
Thanked 982 Times in 236 Posts
peterf1999 is on a distinguished road
Here you go for usage example

Create a FreeArc archive with 'Data1.bin' name and then place it where compiled setup.exe is created.
Attached Files
File Type: 7z Sysinfo_Taskbar_Progress_ISDone_usage_example.7z (1.86 MB, 925 views)

Last edited by peterf1999; 04-05-2014 at 04:18.
Reply With Quote
The Following 8 Users Say Thank You to peterf1999 For This Useful Post:
altef_4 (17-05-2014), ffmla (12-11-2016), Gigachad (08-03-2022), GTX590 (16-02-2016), JRD! (16-02-2016), Nemko (22-05-2018), saradaddy (10-02-2016), yasserdivar (04-10-2021)
  #3  
Old 15-04-2014, 07:30
Dante1995 Dante1995 is offline
Banned
 
Join Date: Feb 2014
Location: Black Hole
Posts: 297
Thanks: 116
Thanked 481 Times in 162 Posts
Dante1995 is on a distinguished road
no show Video Card Memory
ex:
GeForce 7600 GT
Graphics Bus Technology PCI Express ®
Memory 256MB
Memory Interface 128-bit
Memory Bandwidth (GB / s) 22.4
Fill Rate (billion pixels / sec.) 6.7
Vertices / s. (Millions) 700
Pixels per clock (peak) 12
RAMDAC (MHz) 400

Last edited by Dante1995; 28-12-2014 at 21:54.
Reply With Quote
  #4  
Old 15-04-2014, 23:33
peterf1999's Avatar
peterf1999 peterf1999 is offline
Die Hard Member
 
Join Date: Nov 2008
Location: Italy
Posts: 928
Thanks: 14
Thanked 982 Times in 236 Posts
peterf1999 is on a distinguished road
Quote:
Originally Posted by Dante1995 View Post
no show Video Card Memory
ex:
GeForce 7600 GT
Graphics Bus Technology PCI Express ®
Memory 256MB
Memory Interface 128-bit
Memory Bandwidth (GB / s) 22.4
Fill Rate (billion pixels / sec.) 6.7
Vertices / s. (Millions) 700
Pixels per clock (peak) 12
RAMDAC (MHz) 400
You can't retrieve this supplementary information through the WMI class (http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx), Directx or Nvidia or AMD api calls needed.
Reply With Quote
  #5  
Old 16-04-2014, 01:31
Dante1995 Dante1995 is offline
Banned
 
Join Date: Feb 2014
Location: Black Hole
Posts: 297
Thanks: 116
Thanked 481 Times in 162 Posts
Dante1995 is on a distinguished road
Ok .. Winzoz is limited
known only by your screen 7Utimate of 8 is guaranteed?
Reply With Quote
  #6  
Old 04-05-2014, 04:22
peterf1999's Avatar
peterf1999 peterf1999 is offline
Die Hard Member
 
Join Date: Nov 2008
Location: Italy
Posts: 928
Thanks: 14
Thanked 982 Times in 236 Posts
peterf1999 is on a distinguished road
  • Fixed the issues of GetSysInfo procedure on Windows XP, Windows 8.x.
Reply With Quote
The Following 4 Users Say Thank You to peterf1999 For This Useful Post:
altef_4 (17-05-2014), Razor12911 (04-05-2014), y_thelastknight (04-05-2014), ZackBohne (25-06-2015)
  #7  
Old 15-05-2014, 11:41
peterf1999's Avatar
peterf1999 peterf1999 is offline
Die Hard Member
 
Join Date: Nov 2008
Location: Italy
Posts: 928
Thanks: 14
Thanked 982 Times in 236 Posts
peterf1999 is on a distinguished road
  • Added CheckFileSHA1 function to dll.
Reply With Quote
The Following 3 Users Say Thank You to peterf1999 For This Useful Post:
altef_4 (17-05-2014), Razor12911 (12-12-2014), y_thelastknight (15-05-2014)
  #8  
Old 17-05-2014, 10:06
altef_4's Avatar
altef_4 altef_4 is offline
Registered User
 
Join Date: Mar 2012
Location: Ukraine
Posts: 361
Thanks: 248
Thanked 1,018 Times in 239 Posts
altef_4 is on a distinguished road
Quote:
Originally Posted by peterf1999 View Post
  • Added CheckFileSHA1 function to dll.
small error, if file for check not exists - error.
p.s. in attachment working module+example for those who don't know how to use this library.
p.p.s. can you provide me example how do you create callback for inno setup in delphi without CallbackCtrl.dll/InnoCallback.dll/CallbackAddr ?
Attached Files
File Type: 7z Isab_MODULE+EXAMPLE.7z (3.2 KB, 191 views)
Reply With Quote
The Following 5 Users Say Thank You to altef_4 For This Useful Post:
ffmla (18-06-2017), Nemko (22-05-2018), peterf1999 (17-05-2014), Razor12911 (12-12-2014), y_thelastknight (17-05-2014)
  #9  
Old 17-05-2014, 10:58
peterf1999's Avatar
peterf1999 peterf1999 is offline
Die Hard Member
 
Join Date: Nov 2008
Location: Italy
Posts: 928
Thanks: 14
Thanked 982 Times in 236 Posts
peterf1999 is on a distinguished road
Quote:
Originally Posted by altef_4 View Post
small error, if file for check not exists - error.
p.s. in attachment working module+example for those who don't know how to use this library.
p.p.s. can you provide me example how do you create callback for inno setup in delphi without CallbackCtrl.dll/InnoCallback.dll/CallbackAddr ?
Code:
type THashProgress = function(OverallProgress,FileProgress: Integer): Boolean of object;




function CheckFileSHA1(Filename,SHA1HashHex: AnsiString; PctOfTotal: integer; callback: THashProgress): integer export; stdcall;
begin
...

if not callback(FileProgress+OverallProgress,round(FileProgress*100/PctOfTotal)) then begin
      Result:=-1;
      break;
      end;
...

end;
I didn't intentionally handle the exception of TFileStream, because the file must exist.

Last edited by peterf1999; 17-05-2014 at 11:44.
Reply With Quote
The Following 2 Users Say Thank You to peterf1999 For This Useful Post:
altef_4 (17-05-2014), y_thelastknight (18-05-2014)
  #10  
Old 18-05-2014, 04:58
peterf1999's Avatar
peterf1999 peterf1999 is offline
Die Hard Member
 
Join Date: Nov 2008
Location: Italy
Posts: 928
Thanks: 14
Thanked 982 Times in 236 Posts
peterf1999 is on a distinguished road
  • Added GetFileSHA1 function to dll.
  • CheckFileSHA1 : no more exception is raised if the file to check is not found, an error code is returned from function (see the 1st post).
Reply With Quote
The Following 4 Users Say Thank You to peterf1999 For This Useful Post:
altef_4 (19-05-2014), arkantos7 (18-05-2014), Razor12911 (19-05-2014), y_thelastknight (18-05-2014)
  #11  
Old 19-05-2014, 08:23
Razor12911's Avatar
Razor12911 Razor12911 is offline
Noob
 
Join Date: Jul 2012
Location: South Africa
Posts: 3,746
Thanks: 2,141
Thanked 11,099 Times in 2,295 Posts
Razor12911 is on a distinguished road
Nice, Great. By the way what program did you use to create the dll. I currently use Delphi XE3 and I get errors and I don't know what to do. I can only pass strings as PAnsiChar and Integers and cannot Pass Int64. I tried Lararus and same thing. so what program?
Reply With Quote
  #12  
Old 20-05-2014, 04:09
peterf1999's Avatar
peterf1999 peterf1999 is offline
Die Hard Member
 
Join Date: Nov 2008
Location: Italy
Posts: 928
Thanks: 14
Thanked 982 Times in 236 Posts
peterf1999 is on a distinguished road
Quote:
Originally Posted by Razor12911 View Post
By the way what program did you use to create the dll. I currently use Delphi XE3 and I get errors and I don't know what to do.
The last version was compiled with XE5, however XE3 works as well.

Quote:
Originally Posted by Razor12911 View Post
I can only pass strings as PAnsiChar and Integers and cannot Pass Int64. I tried Lararus and same thing. so what program?
Only the latest UNICODE versions (v5.5.3 or later) of Inno Setup can handle 64 bit integers.
Reply With Quote
The Following User Says Thank You to peterf1999 For This Useful Post:
Razor12911 (20-05-2014)
  #13  
Old 20-05-2014, 08:17
Razor12911's Avatar
Razor12911 Razor12911 is offline
Noob
 
Join Date: Jul 2012
Location: South Africa
Posts: 3,746
Thanks: 2,141
Thanked 11,099 Times in 2,295 Posts
Razor12911 is on a distinguished road
Ok thanks will try it out.
Reply With Quote
  #14  
Old 22-06-2014, 14:39
Dante1995 Dante1995 is offline
Banned
 
Join Date: Feb 2014
Location: Black Hole
Posts: 297
Thanks: 116
Thanked 481 Times in 162 Posts
Dante1995 is on a distinguished road
please

you can get the code isab for this

Last edited by Dante1995; 28-12-2014 at 21:54.
Reply With Quote
  #15  
Old 25-06-2014, 18:30
Cesar82's Avatar
Cesar82 Cesar82 is offline
Registered User
 
Join Date: May 2011
Location: Brazil
Posts: 1,028
Thanks: 1,740
Thanked 2,200 Times in 752 Posts
Cesar82 is on a distinguished road
isab.dll v0.0.3.0 work in Windows XP SP3

isab.dll v0.0.4.1 not work in Windows XP SP3
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
INNO TROUBLESHOOT - Tutorials and Answers about INNO Setup REV0 Conversion Tutorials 129 21-05-2021 06:51
Inno Setup: Additional Libraries altef_4 Conversion Tutorials 50 21-10-2020 10:59
INNO TUTORIAL - Using Unicode and ANSI Versions of INNO Setup REV0 Conversion Tutorials 51 26-03-2015 07:57
Tutorial using CI 8.0.0 yener90 Conversion Tutorials 424 21-10-2014 10:49



All times are GMT -7. The time now is 14:55.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright 2000-2020, FileForums @ https://fileforums.com