Einzelnen Beitrag anzeigen

THE MATRIX

Registriert seit: 26. Jul 2003
62 Beiträge
 

Re: Auslesen der Eigenschaften eines Control-Panel-Applets

  Alt 4. Aug 2003, 15:51
KP ob das hier hin soll/darf - wenn nein lösch es

hier mal das ding als komponente
gibt den Caption und den Hint aus...

Delphi-Quellcode:
unit MCSVSystemAppletCaption;

interface

uses
  SysUtils, Classes, cpl, windows;

type
  TMCSVSystemAppletCaption = class(TComponent)
  private
   FCPLFile: String;
   FCplName: String;
   FCPLHint: String;
   procedure SetFCPLFile(Value: String);
   procedure SetFCPLName(Value: String);
   procedure SetFCPLHint(Value: String);
  protected
    { Protected declarations }
  public
   constructor Create(AOwner: TComponent);override;
  published
   property CPLfile: String read FCPLFile write SetFCplFile;
   property CPLCaption: String read FCPLName write SetFCplName;
   Property CPLHint: String read FCPLHint write SetFCPLHint;
  end;

implementation

var
 Names: PChar;
 FSysDir: String;

constructor TMCSVSystemAppletCaption.Create(AOwner: TComponent);
begin
Inherited Create(AOwner);
    GetMem( Names, MAX_PATH+1 );
    GetSystemDirectory(Names, MAX_PATH+1);
    FSysdir := StrPas(Names);

end;

procedure TMCSVSystemAppletCaption.SetFCPLFile(Value: String);
var
  DLLHandle: Cardinal;
  I: Integer;
  P: Pointer;
  CPLInfo: TCPLInfo;
  ResStringRec: TResStringRec;
begin
FCPLFile := Value;
  DLLHandle := LoadLibrary(PChar(FSysDir + '\' + value));
  if DLLHandle <> INVALID_HANDLE_VALUE then
  try
    P := GetProcAddress(DLLHandle, 'CPlApplet');
    if P <> nil then
    begin
      for I := 0 to Pred(TCPLApplet(P)(HInstance, CPL_GETCOUNT, 0, 0)) do
      begin
        TCPLApplet(P)(HInstance, CPL_INQUIRE, I, Integer(@CPLInfo));
        ResStringRec.Module := @DLLHandle;
        ResStringRec.Identifier := CPLInfo.idName;
        fcplname := LoadResString(@ResStringRec);
        ResStringRec.Identifier := CPLInfo.idInfo;
        fcplhint := LoadResString(@ResStringRec);
      end;
    end;
  finally
    FreeLibrary(DLLHandle);
  end;
end;

procedure TMCSVSystemAppletCaption.SetFCPLHint(Value: String);
begin
FCPLHint := Value;
end;

procedure TMCSVSystemAppletCaption.SetFCPLName(Value: String);
begin
fcplname := Value;
end;

end.
kann man ja vielleicht noch erweitern so mit Icon usw. *g* .....
  Mit Zitat antworten Zitat