Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How  to get Control Panel Applet Info

Posted on 2000-02-29
11
Medium Priority
?
350 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

719 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