🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.vcl.components
1 messages
1 total messages Started by Lina Scarpellini Fri, 07 Jul 2000 00:00
Is it impossible to get package info about any Exe specified by its name?
#22
Author: Lina Scarpellini
Date: Fri, 07 Jul 2000 00:00
216 lines
8454 bytes
--------------923532C13090A88EB32D7BD5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I want to retrieve information about which packages are used by my
application so I created an utility that among other things display this
piece of information.

I have tried to adapt my initial code so to pass an application name as
a parameter and retrieve the same information. The problem is that is
works only from the application that contains the code. If I specify a
different application name for which I want to get information, I get
variant conversion error. How can I bypass this? Does it mean I can only
get information on running processes?


procedure ShowInfoProc (const Name: string;
  NameType: TNameType; Flags: Byte; Param: Pointer);
var
  FlagStr: string;
begin
  FlagStr := ' ';
  if Flags and ufMainUnit <> 0 then
    FlagStr := FlagStr + 'Main Unit ';
  if Flags and ufPackageUnit <> 0 then
    FlagStr := FlagStr + 'Package Unit ';
  if Flags and ufWeakUnit <> 0 then
    FlagStr := FlagStr + 'Weak Unit ';
  if FlagStr <> ' ' then
    FlagStr := ' (' + FlagStr + ')';
  with DocEditForm.TreePackages.Items do
    case NameType of
      ntContainsUnit:
        AddChild (ContNode, Name + FlagStr);
      ntRequiresPackage:
        AddChild (ReqNode, Name);
    end;
end;

function TDocEditForm.GetModuleName: string;
begin
  Result := ChangeFileExt(DocName, 'EXE');
end;

function ForEachModule (HInstance: Longint; Data: Pointer): Boolean;
var
  Flags: Integer;
  ModuleName, ModuleDesc: string;
  ModuleNode: TTreeNode;
begin
  with DocEditForm.TreePackages.Items do
  begin
    ModuleName := DocEditForm.GetModuleName;
    ShowMessage('ModuleName ' + ModuleName);
    SetLength (ModuleName, 200);

    GetModuleFileName(HInstance, PChar (ModuleName), Length
(ModuleName));
    ModuleName := PChar (ModuleName); // fixup
    ModuleNode := Add (nil, ModuleName);

    // get description and add fixed nodes
    ModuleDesc := GetPackageDescription (PChar (ModuleName));
    ContNode := AddChild (ModuleNode, 'Contains');
    ReqNode := AddChild (ModuleNode, 'Requires');

    // add information if the module is a package
    GetPackageInfo (HInstance, nil, Flags, ShowInfoProc);
    if ModuleDesc <> '' then
    begin
      AddChild (ModuleNode,
        'Description: ' + ModuleDesc);
      if Flags and pfDesignOnly = pfDesignOnly then
        AddChild (ModuleNode, 'Design Only');
      if Flags and pfRunOnly = pfRunOnly then
        AddChild (ModuleNode, 'Run Only');
    end;
  end;
  Result := True;
end;

procedure TDocEditForm.Open1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
 begin
   Document.Clear;
   Document.Lines.LoadFromFile(OpenDialog1.FileName);
   Document.Modified := False;
   DocName := OpenDialog1.FileName;
   Caption := DefCaption + ' - ' + DocName;
   EnumModules(ForEachModule, nil);
 end;
end;

In the Open button's click, I open a map file and I want to get
information on the corresponding exe file. What do I need to change ?

Thanks in advance! Any help, suggestions or hints are welcomed.
Please send your answer to the email address below.

Lina
lina@info-internet.net


--------------923532C13090A88EB32D7BD5
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
I want to retrieve information about which packages are used by my application
so I created an utility that among other things display this piece of information.
<BR>&nbsp;
<BR>I have tried to adapt my initial code so to pass an application name
as a parameter and retrieve the same information. The problem is that is
works only from the application that contains the code. If I specify a
different application name for which I want to get information, I get variant
conversion error. How can I bypass this? Does it mean I can only get information
on running processes?
<BR>&nbsp;
<BR>&nbsp;
<BR>procedure ShowInfoProc (const Name: string;
<BR>&nbsp; NameType: TNameType; Flags: Byte; Param: Pointer);
<BR>var
<BR>&nbsp; FlagStr: string;
<BR>begin
<BR>&nbsp; FlagStr := ' ';
<BR>&nbsp; if Flags and ufMainUnit &lt;> 0 then
<BR>&nbsp;&nbsp;&nbsp; FlagStr := FlagStr + 'Main Unit ';
<BR>&nbsp; if Flags and ufPackageUnit &lt;> 0 then
<BR>&nbsp;&nbsp;&nbsp; FlagStr := FlagStr + 'Package Unit ';
<BR>&nbsp; if Flags and ufWeakUnit &lt;> 0 then
<BR>&nbsp;&nbsp;&nbsp; FlagStr := FlagStr + 'Weak Unit ';
<BR>&nbsp; if FlagStr &lt;> ' ' then
<BR>&nbsp;&nbsp;&nbsp; FlagStr := ' (' + FlagStr + ')';
<BR>&nbsp; with DocEditForm.TreePackages.Items do
<BR>&nbsp;&nbsp;&nbsp; case NameType of
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ntContainsUnit:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddChild (ContNode, Name
+ FlagStr);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ntRequiresPackage:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddChild (ReqNode, Name);
<BR>&nbsp;&nbsp;&nbsp; end;
<BR>end;
<BR>&nbsp;
<BR>function TDocEditForm.GetModuleName: string;
<BR>begin
<BR>&nbsp; Result := ChangeFileExt(DocName, 'EXE');
<BR>end;
<BR>&nbsp;
<BR>function ForEachModule (HInstance: Longint; Data: Pointer): Boolean;
<BR>var
<BR>&nbsp; Flags: Integer;
<BR>&nbsp; ModuleName, ModuleDesc: string;
<BR>&nbsp; ModuleNode: TTreeNode;
<BR>begin
<BR>&nbsp; with DocEditForm.TreePackages.Items do
<BR>&nbsp; begin
<BR>&nbsp;&nbsp;&nbsp; ModuleName := DocEditForm.GetModuleName;
<BR>&nbsp;&nbsp;&nbsp; ShowMessage('ModuleName ' + ModuleName);
<BR>&nbsp;&nbsp;&nbsp; SetLength (ModuleName, 200);
<BR>&nbsp;
<BR>&nbsp;&nbsp;<FONT COLOR="#FF0000">&nbsp; GetModuleFileName(HInstance,
PChar (ModuleName), Length (ModuleName));</FONT>
<BR>&nbsp;&nbsp;&nbsp; ModuleName := PChar (ModuleName); // fixup
<BR>&nbsp;&nbsp;&nbsp; ModuleNode := Add (nil, ModuleName);
<BR>&nbsp;
<BR>&nbsp;&nbsp;&nbsp; // get description and add fixed nodes
<BR><FONT COLOR="#FF0000">&nbsp;&nbsp;&nbsp; ModuleDesc := GetPackageDescription
(PChar (ModuleName));</FONT>
<BR>&nbsp;&nbsp;&nbsp; ContNode := AddChild (ModuleNode, 'Contains');
<BR>&nbsp;&nbsp;&nbsp; ReqNode := AddChild (ModuleNode, 'Requires');
<BR>&nbsp;
<BR>&nbsp;&nbsp;&nbsp; // add information if the module is a package
<BR><FONT COLOR="#FF0000">&nbsp;&nbsp;&nbsp; GetPackageInfo (HInstance,
nil, Flags, ShowInfoProc);</FONT>
<BR>&nbsp;&nbsp;&nbsp; if ModuleDesc &lt;> '' then
<BR>&nbsp;&nbsp;&nbsp; begin
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddChild (ModuleNode,
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Description: ' + ModuleDesc);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if Flags and pfDesignOnly = pfDesignOnly
then
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddChild (ModuleNode, 'Design
Only');
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if Flags and pfRunOnly = pfRunOnly then
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddChild (ModuleNode, 'Run
Only');
<BR>&nbsp;&nbsp;&nbsp; end;
<BR>&nbsp; end;
<BR>&nbsp; Result := True;
<BR>end;
<BR>&nbsp;
<BR>procedure TDocEditForm.Open1Click(Sender: TObject);
<BR>begin
<BR>&nbsp; if OpenDialog1.Execute then
<BR>&nbsp;begin
<BR>&nbsp;&nbsp; Document.Clear;
<BR>&nbsp;&nbsp; Document.Lines.LoadFromFile(OpenDialog1.FileName);
<BR>&nbsp;&nbsp; Document.Modified := False;
<BR>&nbsp;&nbsp; DocName := OpenDialog1.FileName;
<BR>&nbsp;&nbsp; Caption := DefCaption + ' - ' + DocName;
<BR>&nbsp;&nbsp; EnumModules(ForEachModule, nil);
<BR>&nbsp;end;
<BR>end;
<BR>&nbsp;
<BR>In the Open button's click, I open a map file and I want to get information
on the corresponding exe file. What do I need to change ?
<BR>&nbsp;
<BR>Thanks in advance! Any help, suggestions or hints are welcomed.
<BR>Please send your answer to the email address below.

<P>Lina
<BR>lina@info-internet.net
<BR>&nbsp;</HTML>

--------------923532C13090A88EB32D7BD5--
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads