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?
Author: Lina Scarpellini
Date: Fri, 07 Jul 2000 00:00
Date: Fri, 07 Jul 2000 00:00
216 lines
8454 bytes
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>
<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>
<BR>
<BR>procedure ShowInfoProc (const Name: string;
<BR> NameType: TNameType; Flags: Byte; Param: Pointer);
<BR>var
<BR> FlagStr: string;
<BR>begin
<BR> FlagStr := ' ';
<BR> if Flags and ufMainUnit <> 0 then
<BR> FlagStr := FlagStr + 'Main Unit ';
<BR> if Flags and ufPackageUnit <> 0 then
<BR> FlagStr := FlagStr + 'Package Unit ';
<BR> if Flags and ufWeakUnit <> 0 then
<BR> FlagStr := FlagStr + 'Weak Unit ';
<BR> if FlagStr <> ' ' then
<BR> FlagStr := ' (' + FlagStr + ')';
<BR> with DocEditForm.TreePackages.Items do
<BR> case NameType of
<BR> ntContainsUnit:
<BR> AddChild (ContNode, Name
+ FlagStr);
<BR> ntRequiresPackage:
<BR> AddChild (ReqNode, Name);
<BR> end;
<BR>end;
<BR>
<BR>function TDocEditForm.GetModuleName: string;
<BR>begin
<BR> Result := ChangeFileExt(DocName, 'EXE');
<BR>end;
<BR>
<BR>function ForEachModule (HInstance: Longint; Data: Pointer): Boolean;
<BR>var
<BR> Flags: Integer;
<BR> ModuleName, ModuleDesc: string;
<BR> ModuleNode: TTreeNode;
<BR>begin
<BR> with DocEditForm.TreePackages.Items do
<BR> begin
<BR> ModuleName := DocEditForm.GetModuleName;
<BR> ShowMessage('ModuleName ' + ModuleName);
<BR> SetLength (ModuleName, 200);
<BR>
<BR> <FONT COLOR="#FF0000"> GetModuleFileName(HInstance,
PChar (ModuleName), Length (ModuleName));</FONT>
<BR> ModuleName := PChar (ModuleName); // fixup
<BR> ModuleNode := Add (nil, ModuleName);
<BR>
<BR> // get description and add fixed nodes
<BR><FONT COLOR="#FF0000"> ModuleDesc := GetPackageDescription
(PChar (ModuleName));</FONT>
<BR> ContNode := AddChild (ModuleNode, 'Contains');
<BR> ReqNode := AddChild (ModuleNode, 'Requires');
<BR>
<BR> // add information if the module is a package
<BR><FONT COLOR="#FF0000"> GetPackageInfo (HInstance,
nil, Flags, ShowInfoProc);</FONT>
<BR> if ModuleDesc <> '' then
<BR> begin
<BR> AddChild (ModuleNode,
<BR> 'Description: ' + ModuleDesc);
<BR> if Flags and pfDesignOnly = pfDesignOnly
then
<BR> AddChild (ModuleNode, 'Design
Only');
<BR> if Flags and pfRunOnly = pfRunOnly then
<BR> AddChild (ModuleNode, 'Run
Only');
<BR> end;
<BR> end;
<BR> Result := True;
<BR>end;
<BR>
<BR>procedure TDocEditForm.Open1Click(Sender: TObject);
<BR>begin
<BR> if OpenDialog1.Execute then
<BR> begin
<BR> Document.Clear;
<BR> Document.Lines.LoadFromFile(OpenDialog1.FileName);
<BR> Document.Modified := False;
<BR> DocName := OpenDialog1.FileName;
<BR> Caption := DefCaption + ' - ' + DocName;
<BR> EnumModules(ForEachModule, nil);
<BR> end;
<BR>end;
<BR>
<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>
<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> </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