Solved

How  to get Control Panel Applet Info

Posted on 2000-02-29
11
344 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
Comment Utility
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
Comment Utility
Adjusted points to 150
0
 

Author Comment

by:cardax
Comment Utility
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
 
LVL 12

Expert Comment

by:rwilson032697
Comment Utility
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
Comment Utility
Thanks Raymond, close but no cigar...

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

Cheers,

Steve
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:cardax
Comment Utility
Adjusted points from 150 to 200
0
 

Author Comment

by:cardax
Comment Utility
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
Comment Utility
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
Comment Utility
Oops, meant that to be an answer...
0
 

Author Comment

by:cardax
Comment Utility
Adjusted points from 200 to 400
0
 

Author Comment

by:cardax
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now