PackForm.pas
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit PackForm;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   StdCtrls, ComCtrls, ExtCtrls, TeeProcs, TeEngine, Chart, Mask,
  6.   DBCtrls;
  7. type
  8.   TForm1 = class(TForm)
  9.     TreeView1: TTreeView;
  10.     DBEdit1: TDBEdit;
  11.     Chart1: TChart;
  12.     procedure FormCreate(Sender: TObject);
  13.   private
  14.     { Private declarations }
  15.   public
  16.     { Public declarations }
  17.   end;
  18. var
  19.   Form1: TForm1;
  20. implementation
  21. {$R *.DFM}
  22. var
  23.   ContNode, ReqNode: TTreeNode;
  24. procedure ShowInfoProc (const Name: string;
  25.   NameType: TNameType; Flags: Byte; Param: Pointer);
  26. var
  27.   FlagStr: string;
  28. begin
  29.   FlagStr := ' ';
  30.   if Flags and ufMainUnit <> 0 then
  31.     FlagStr := FlagStr + 'Main Unit ';
  32.   if Flags and ufPackageUnit <> 0 then
  33.     FlagStr := FlagStr + 'Package Unit ';
  34.   if Flags and ufWeakUnit <> 0 then
  35.     FlagStr := FlagStr + 'Weak Unit ';
  36.   if FlagStr <> ' ' then
  37.     FlagStr := ' (' + FlagStr + ')';
  38.   with Form1.TreeView1.Items do
  39.     case NameType of
  40.       ntContainsUnit:
  41.         AddChild (ContNode, Name + FlagStr);
  42.       ntRequiresPackage:
  43.         AddChild (ReqNode, Name);
  44.     end;
  45. end;
  46. function ForEachModule (HInstance: Longint;
  47.   Data: Pointer): Boolean;
  48. var
  49.   Flags: Integer;
  50.   ModuleName, ModuleDesc: string;
  51.   ModuleNode: TTreeNode;
  52. begin
  53.   with Form1.TreeView1.Items do
  54.   begin
  55.     SetLength (ModuleName, 200);
  56.     GetModuleFileName (HInstance,
  57.       PChar (ModuleName), Length (ModuleName));
  58.     ModuleName := PChar (ModuleName); // fixup
  59.     ModuleNode := Add (nil, ModuleName);
  60.     // get description and add fixed nodes
  61.     ModuleDesc := GetPackageDescription (PChar (ModuleName));
  62.     ContNode := AddChild (ModuleNode, 'Contains');
  63.     ReqNode := AddChild (ModuleNode, 'Requires');
  64.     // add information if the module is a package
  65.     GetPackageInfo (HInstance, nil,
  66.       Flags, ShowInfoProc);
  67.     if ModuleDesc <> '' then
  68.     begin
  69.       AddChild (ModuleNode,
  70.         'Description: ' + ModuleDesc);
  71.       if Flags and pfDesignOnly = pfDesignOnly then
  72.         AddChild (ModuleNode, 'Design Only');
  73.       if Flags and pfRunOnly = pfRunOnly then
  74.         AddChild (ModuleNode, 'Run Only');
  75.     end;
  76.   end;
  77.   Result := True;
  78. end;
  79. procedure TForm1.FormCreate(Sender: TObject);
  80. begin
  81.   EnumModules(ForEachModule, nil);
  82. end;
  83. end.