AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Code-Bibliothek Library: Windows API / MS.NET Framework API Delphi Auslesen der Eigenschaften eines Control-Panel-Applets
Thema durchsuchen
Ansicht
Themen-Optionen

Auslesen der Eigenschaften eines Control-Panel-Applets

Ein Thema von sakura · begonnen am 3. Aug 2003 · letzter Beitrag vom 4. Aug 2003
Antwort Antwort
Benutzerbild von sakura
sakura

Registriert seit: 10. Jun 2002
Ort: München
11.412 Beiträge
 
Delphi 11 Alexandria
 
#1

Auslesen der Eigenschaften eines Control-Panel-Applets

  Alt 3. Aug 2003, 13:28
Jedes Control-Panel-Applet muss die Funktion CPlApplet exportieren. Diese Funktion übernimmt die gesamte Steuerung des Applets nach aussen.

Die folgende Funktion liesst die Anzeige-Namen aller Sub-Module einer CPL-Datei aus.
Delphi-Quellcode:
uses
  Cpl;

...

// PROC: GetCPLCaptions
// Returns the Captions of all CPL-Sub-Modules in a string list.
// NOTE: One CPL-File may display multiple sub-modules in the system settings
procedure GetCPLCaptions(CPLFileName: String; Strings: TStrings);
var
  DLLHandle: Cardinal;
  I, SubModuleCount: Integer;
  CPLAppletFunc: Pointer;
  CPLInfo: TCPLInfo;
  ResStringRec: TResStringRec;
begin
  // load library
  DLLHandle := LoadLibrary(PChar(CPLFileName));
  if DLLHandle <> INVALID_HANDLE_VALUE then
  try
    // library loaded successfully
    // load entry-point procedure
    CPLAppletFunc := GetProcAddress(DLLHandle, 'CPlApplet');
    if CPLAppletFunc <> nil then
    begin
      // entry-point found
      // get count of sub modules within CPL-file
      SubModuleCount := TCPLApplet(CPLAppletFunc)(HInstance, CPL_GETCOUNT, 0,
          0);
      // iterate all sub-modules (0-based list)
      for I := 0 to Pred(SubModuleCount) do
      begin
        // get resource ids for current sub-module
        TCPLApplet(CPLAppletFunc)(HInstance, CPL_INQUIRE, I, Integer(@CPLInfo));
        // load string resource for caption
        ResStringRec.Module := @DLLHandle;
        ResStringRec.Identifier := CPLInfo.idName;
        // and insert into string list
        Strings.Add(LoadResString(@ResStringRec));
      end;
    end;
  finally
    // unload library
    FreeLibrary(DLLHandle);
  end;
end;
Der Prozedur muss nur der Name der DLL (inkl. Pfad) und eine StringListe zur Aufnahme der Captions übergeben werden. Folgender Code zeigt ein Beispiel zur Nutzung
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Memo1.Clear;
  GetCPLCaptions('C:\WINNT\system32\hdwwiz.cpl', Memo1.Lines);
end;
Viel Erfolg

......
Daniel W.
Ich bin nicht zurück, ich tue nur so
  Mit Zitat antworten Zitat
THE MATRIX

Registriert seit: 26. Jul 2003
62 Beiträge
 
#2

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
Antwort Antwort

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:12 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz