Solved

How  to get Control Panel Applet Info

Posted on 2000-02-29
11
346 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 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