Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8134803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:10:32+00:00 2026-06-06T10:10:32+00:00

Well I’m stumped. I’m writing an installation support add-on for Smart Install Maker that

  • 0

Well I’m stumped.
I’m writing an installation support add-on for Smart Install Maker that will install some components for me- AlphaControls 🙂

And the add-on is a console application. But for some reason [down in the code] for adding packages to the “Known Packages” registry location, it wants to add an additional registry entry, even though the array size is only setup for 3. It’s trying to add a .DPK file, even though the array is setup for .BPL. Soo… what the hell????
It works and all, except for that last nagging bit it tries to add.
Compile size is about 97/98k, after optimizing and compressing shrinks down to about 48k

So I guess my question is, can anyone spot the error I seem to be overlooking?
YES I KNOW- INNO SETUP, but… I’ve already spent the money on Smart Install Maker so I gotta use it.
No compile errors, justs adds an extra non .bpl file to registry

Code is as follows…

{Smart Install Maker installation support for components}
{for Delphi 7.0 environment only}
program pakghlp;

{$APPTYPE CONSOLE}

uses
  Windows,
  SysUtils,
  Classes,
  Registry;

var  SPath,
   BPLPath,
   IDERoot,
   DPKName: string;

const
 BaseName = 'AlphaControls';

 PackageRoot = 'AlphaControls\';

 DPKFiles: array[1..5]
  of string = ('acntD7_R.dpk',
               'acntD7.dpk',
               'aceD7_R.dpk',
               'aceD7.dpk',
               'AlphaDB7.dpk');

 DPKArraySize = 5;

 BPLFiles: array[1..3]
 of string = ('aceD7.bpl',
              'acntD7.bpl',
              'AlphaDB7.bpl');

 BPLDetails: array[1..3]
 of string = ('AlphaControls extra',
              'AlphaControls',
              'AlphaControls DB-aware pack');

 BPLFileQty = 3;

  LookFor: array[1..2] of string = ('*.dcp','*.bpl');
  LookForQty = 2;

  RegPath = ';$(DELPHI)\Components\AlphaControls';

procedure InitVariables;
var
    RegKey: TRegistry;
 TargetKey: string;
   LibPath: string;
begin
 RegKey:= TRegistry.Create;
   try
     RegKey.RootKey := HKEY_CURRENT_USER;
     TargetKey:= 'Software\Borland\Delphi\7.0';
     if RegKey.OpenKeyReadOnly(TargetKey) then
       begin
        IDERoot:= RegKey.ReadString('RootDir');
        RegKey.CloseKey;

        TargetKey:= 'Software\Borland\Delphi\7.0\Library';
        RegKey.OpenKeyReadOnly(TargetKey);
        SPath:= RegKey.ReadString('Search Path');
        LibPath:= RegKey.ReadString('Package DPL Output');
        RegKey.CloseKey;

        LibPath:= StringReplace(LibPath,'$(DELPHI)','',[rfIgnoreCase]);
        BPLPath:= IDERoot + LibPath + '\';
       end;
    finally
     RegKey.Free;
    end;
end;

procedure GetListing(const SearchFor: String; ImportList:TStringList);
var SrchResult : TSearchRec;
begin
if FindFirst(SearchFor, faAnyFile, SrchResult) = 0 then
  begin
    repeat
     ImportList.Add(SrchResult.name);
    until FindNext(SrchResult) <> 0;
    FindClose(SrchResult);
  end;
end;

procedure GetBaseNames(Listing: TStringList);
var TempList: TStringList;
           i: integer;
    BaseName: string;
begin
  TempList:= TStringList.Create;
  TempList.Delimiter:= ';';
  TempList.DelimitedText:= SPath;
  Listing.Clear;
  for i:= 0 to TempList.Count - 1 do
    begin
    BaseName:= TempList[i];
    StringReplace(BaseName,'$(DELPHI)','X:\Dummy\Folder',[rfIgnoreCase]);
    Listing.Add(ExtractFileName(BaseName));
    end;
  TempList.Free;
end;

function AlreadyExists: boolean;
var CheckList: TStringList;
            i: integer;
    Installed: boolean;
begin
  CheckList:= TStringList.Create;
  GetBaseNames(CheckList);

  for i:= 0 to CheckList.Count -1 do
   begin
     if CheckList[i] = BaseName
      then Installed:= true;
       if Installed = true then break;
     Installed:= false;
   end;
CheckList.Free;
Result:= Installed;
end;

procedure ProcessIDE(InstallType: integer);
var RegKey: TRegistry;
  TempList: TStringList;
       i,j: integer;
  NewSPath,
  RegName,
  RegValue,
  DelEntry: string;
begin
RegKey:= TRegistry.Create;
  case InstallType of

    0:  begin {-uninstall}
         TempList:= TStringList.Create;
         TempList.Delimiter:= ';';
         TempList.DelimitedText:= SPath;
         DelEntry:= copy(RegPath,2,Length(RegPath));
         for i:= 0 to TempList.Count - 1 do
          begin
            if TempList[i] = DelEntry
            then
             begin
              Templist.BeginUpdate;
              Templist.Delete(i);
              TempList.EndUpdate;
             end;
          end;
          NewSPath:= TempList.DelimitedText;
          try
            RegKey.RootKey:= HKEY_CURRENT_USER;
            RegKey.OpenKey('Software\Borland\Delphi\7.0\Library',false);
            RegKey.WriteString('Search Path',NewSPath);
            RegKey.CloseKey;

            RegKey.OpenKey('Software\Borland\Delphi\7.0\Known Packages',false);
            for i:= 0 to BPLFileQty do
              begin
                RegName:= BPLPath + BPLFiles[i];
                RegKey.DeleteValue(RegName);
              end;
          finally
            RegKey.CloseKey;
          end;
         TempList.Free;
        end;

    1:  begin {-install}
          SPath:= SPath + RegPath;
          try
            RegKey.RootKey:= HKEY_CURRENT_USER;
            RegKey.OpenKey('Software\Borland\Delphi\7.0\Library',false);
            RegKey.WriteString('Search Path',SPath);
            RegKey.CloseKey;

            RegKey.OpenKey('Software\Borland\Delphi\7.0\Known Packages',false);
            for j:= 0 to BPLFileQty do
              begin
                RegName:= BPLPath + BPLFiles[j];
                RegValue:= BPLDetails[j];
                RegKey.WriteString(RegName,RegValue);
              end;
          finally
          RegKey.CloseKey;
          end;
        end;
  end;
RegKey.Free;
end;

procedure CompilePackage(PackageName: String; Wait: Boolean);
var
  StartInfo : TStartupInfo;
  ProcInfo : TProcessInformation;
  CreateOK : Boolean;
begin
  FillChar(StartInfo,SizeOf(TStartupInfo),#0);
  FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
  StartInfo.cb := SizeOf(TStartupInfo);
  CreateOK := CreateProcess(nil, PChar(PackageName), nil, nil,False,
              CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
              nil, nil, StartInfo, ProcInfo);
  if CreateOK then
    begin
      if Wait then
        WaitForSingleObject(ProcInfo.hProcess, INFINITE);
    end
  else
    begin
      WriteLN('Unable to compile: ' + DPKName);
     end;
  CloseHandle(ProcInfo.hProcess);
  CloseHandle(ProcInfo.hThread);
end;

procedure ProcessPackages;
var Package: string;
          i: integer;
const DCC32 = 'DCC32 ';
begin
  for i:= 1 to DPKArraySize do
  begin
    DPKName:= ExpandFileName(GetCurrentDir + '\..')
            + '\' + PackageRoot + DPKFiles[i];
    Package:= DCC32 + '"' + DPKName + '"';
    CompilePackage(Package,true);
    Sleep(500);
  end;
end;

procedure ProcessFiles(InstallType: integer);
var TempList: TStringList;
    MoveList: TextFile;
         i,j: integer;
    FileFrom,
      FileTo,
   ParentDir,
  SearchType: string;
begin
  case InstallType of

    0:  begin {-uninstall}
          AssignFile(MoveList,'pakghlp.dat');
          Reset(MoveList);
            while not eof(MoveList) do
              begin
                readLn(MoveList,FileFrom);
                if FileExists(FileFrom)
                then DeleteFile(PChar(FileFrom));
              end;
          CloseFile(MoveList);
          DeleteFile(PChar('pakghlp.dat'));
        end;

    1:  begin {-install}
        ProcessPackages;
          if FileExists('pakghlp.dat') then DeleteFile(PChar('pakghlp.dat'));
           AssignFile(MoveList,'pakghlp.dat');
           Rewrite(MoveList);
           ParentDir:= ExpandFileName(GetCurrentDir + '\..') + '\';
           TempList:= TStringList.Create;
          for i:= 1 to LookForQty do // file extension types
            begin
              SearchType:= ParentDir + PackageRoot + LookFor[i];
              GetListing(SearchType,TempList);
              for j:= 0 to Templist.Count - 1 do
                begin
                  FileFrom:= ParentDir + PackageRoot + TempList[j];
                  FileTo:= BPLPath + TempList[j];
                  CopyFile(PChar(FileFrom),PChar(FileTo),False);
                  DeleteFile(PChar(FileFrom));
                  WriteLn(MoveList,FileTo);
                end;
            end;
          CloseFile(MoveList);
        end;
  end;
TempList.Free;
end;

procedure InstallComponents;
begin
  InitVariables;
  if AlreadyExists then ProcessFiles(1) // refresh corrupt .dcu's.
  else
    begin // didn't previously exist
      ProcessFiles(1);
      ProcessIDE(1);
    end;
end;

procedure RemoveComponents;
begin
  InitVariables;
  ProcessFiles(0);
  ProcessIDE(0);
end;

{ ----- Console Application Begins Here ------- }
begin
  if ParamCount =  0 then exit;

  if ParamStr(1) = '-install'
    then InstallComponents;

  if ParamStr(1) = '-uninstall'
    then RemoveComponents

  else exit; // garbage trap
end.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:10:36+00:00Added an answer on June 6, 2026 at 10:10 am

    You issue it seems related to the index used to iterate over the BPLFiles array. which is 1 index based and you are using a 0 index based.

    const
         BPLFiles: array[1..3]
         of string = ('aceD7.bpl',
                      'acntD7.bpl',
                      'AlphaDB7.bpl');
    

    Chage this code

    for i:= 0 to BPLFileQty do
        begin
          RegName:= BPLPath + BPLFiles[i];
          RegKey.DeleteValue(RegName);
        end;
    

    To

    for i:= 1 to BPLFileQty do
        begin
          RegName:= BPLPath + BPLFiles[i];
          RegKey.DeleteValue(RegName);
        end;
    

    And this code

            for j:= 0 to BPLFileQty do
              begin
                RegName:= BPLPath + BPLFiles[j];
                RegValue:= BPLDetails[j];
                RegKey.WriteString(RegName,RegValue);
              end;
    

    To

            for j:= 1 to BPLFileQty do
              begin
                RegName:= BPLPath + BPLFiles[j];
                RegValue:= BPLDetails[j];
                RegKey.WriteString(RegName,RegValue);
              end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, I am storing variables inside of a class that will be used for
Well I'm making a chrome extension that parses some webpage, and that's working right,
well i have a configuration like this in the components part of my config
Well, I have a application which somehow requires some system resources, but how do
Well after much messing about I have finally got a query that gives sales
Well im here because i have a problem. i have code that was created
Well, I have to revive a question that was answered here before. I've made
well. i was use Reactive Extensions (Rx) package async Request,Before you can start writing
Well, that might be a strange question, and maybe just because I'm not familiar
Well, having decided to get to know some of the basic functions in R

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.