Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How  to get Control Panel Applet Info

Posted on 2000-02-29
11
Medium Priority
?
351 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

782 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