Solved

How  to get Control Panel Applet Info

Posted on 2000-02-29
11
347 Views
Last Modified: 2010-04-04
I am using Delphi 4 and would like to obtain the icon and description from a control panel applet file... sample code would be greatly appreciated.
0
Comment
Question by:cardax
  • 7
  • 3
11 Comments
 
LVL 1

Expert Comment

by:wmckie
ID: 2571864
A control panel applet (.cpl file) is a DLL that exports certain functions and procedures so getting the information you shouldn't be a problem. I dont have any examples of what you want but there was an article in the Jan 2000 issue of Delphi Informant which described how to create applets.

http://www.delphizine.com/features/2000/01/di200001pr_f/di200001pr_f.asp

With the information it should be easy to use it against existing applets.

Also the resource explorer example in the demos that come with Delphi can view and extract icons as can Brad Stowers' Icon Controls.

www.delphifreestuff.com

Hope this helps.

Cheers - Walter McKie
0
 

Author Comment

by:cardax
ID: 2607540
Adjusted points to 150
0
 

Author Comment

by:cardax
ID: 2607541
Thanks for the advice, looked into it but still no luck... it appears this may be too hard, even for the experts??

Can anyone help?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 12

Expert Comment

by:rwilson032697
ID: 2610265
Well, I wrote this snippet to do it for myself:

unit Unit7;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses
  cpl;

procedure TForm1.Button1Click(Sender: TObject);
var
  H : THandle;
  F : APPLET_PROC;
  Info : TCPLInfo;
  Stream : TResourceStream;
begin
  H := LoadLibrary('c:\winnt\system32\bdeadmin.cpl');
  F := getprocaddress(H, 'CPlApplet');
  F(Self.Handle, CPL.CPL_INQUIRE, 0, Integer(@Info));

  Stream := TResourceStream.Create(H, inttostr(Info.idIcon), RT_ICON);
  Image1.Picture.Graphic.LoadFromStream(Stream);
end;

end.

Oddly, it doesn't seem to work. The TResourceStream.Create call fails with a message that the resoruce can't be found. I checked with resource workshop and it is there...

Cheers.

Raymond.
0
 

Author Comment

by:cardax
ID: 2610682
Thanks Raymond, close but no cigar...

Come on experts, someone must have the answer to this, Raymond sure got close... ;-)

Cheers,

Steve
0
 

Author Comment

by:cardax
ID: 2630448
Adjusted points from 150 to 200
0
 

Author Comment

by:cardax
ID: 2630449
Can anyone help me on this one please, willing to double points.... to a correct answer.....

cheers,

Steve
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2634077
OK - after a little more trying, I founf that using LoadIcon would do the trick. So here is a working code sample to get the icon, name and info fields from a control panel applet:

Cheers,

Raymond.

unit Unit7;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Image1: TImage;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses
  cpl;

procedure TForm1.Button1Click(Sender: TObject);
var
  H : THandle;
  F : APPLET_PROC;
  Info : TCPLInfo;
  Stream : TResourceStream;
  Icon : ticon;
  s : string;

begin
  H := LoadLibrary('c:\winnt\system32\bdeadmin.cpl');
  @F := getprocaddress(H, 'CPlApplet');
  F(Self.Handle, CPL.CPL_INQUIRE, 0, Integer(@Info));

  Icon := TIcon.Create;
  Icon.Handle := LoadIcon(H, PChar(Info.idIcon));
  Image1.Picture.assign(Icon);

  setlength(s, 1000);
  loadstring(H, Info.idName, PChar(s), 1000);

  label1.caption := s;
  loadstring(H, Info.idInfo, PChar(s), 1000);

  label2.caption := s;
end;

end.
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 400 total points
ID: 2634258
Oops, meant that to be an answer...
0
 

Author Comment

by:cardax
ID: 2639636
Adjusted points from 200 to 400
0
 

Author Comment

by:cardax
ID: 2639637
Thanks heaps Raymond, well done... worth double the points... I am still amazed how what I thought should have been simple, turned out to be a bit of a nightmare.... ;-)

Thanks again,

Steve
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question