Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to extract an applet name from the Control Panel applets Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Aug-02
Category
System
Language
Delphi 2.x
Views
129
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas 

How to extract an applet name from the Control Panel applets

Answer:

*.cpl files are DLL's that export a function called CPlApplet, that you can use to 
get information about the applets contained in the file.

The following code demonstrates what to do. Refer to win32.hlp or 
MSDN.Microsoft.com for more information.
1   
2   function LoadStringFromModule(Module: HInst; ID: Integer): string;
3   const
4     MaxLen = 2000;
5   var
6     Len: Integer;
7   begin
8     SetLength(Result, MaxLen);
9     Len := LoadString(Module, ID, PChar(Result), MaxLen);
10    if Len > 0 then
11      SetLength(Result, Len)
12    else
13      Result := '';
14  end;
15  
16  type
17    TCPlAppletFunc = function(hwndCPl: HWnd; uMsg: DWord; lParam1: Longint;
18      lParam2: Longint): Longint; stdcall;
19  
20  procedure ShowCPLNameAndDescription(FileName: string);
21  var
22    H: HInst;
23    CPlApplet: TCPlAppletFunc;
24    NumberOfApplets: Integer;
25    AppletInfo: TCPLInfo;
26    I: Integer;
27    Name, Desc: string;
28  begin
29    {Load CPL}
30    H := LoadLibrary(PChar(FileName));
31    if H <> 0 then
32    try
33      {Get CPlApplet Function from Module}
34      CPlApplet := GetProcAddress(H, 'CPlApplet');
35      if Assigned(CPlApplet) then
36      begin
37        {Get Number of Applets contained}
38        NumberOfApplets := CPlApplet(Application.Handle, CPL_GETCOUNT, 0, 0);
39        ShowMessage(Format('There are %d Applets in this file', [NumberOfApplets]));
40        {For each Applet in the file}
41        for I := 0 to NumberOfApplets - 1 do
42        begin
43          {Get Name and Desription}
44          CPlApplet(Application.Handle, CPL_INQUIRE, I, Longint(@AppletInfo));
45          Name := LoadStringFromModule(H, AppletInfo.idName);
46          Desc := LoadStringFromModule(H, AppletInfo.idInfo);
47          {And display them}
48          ShowMessage(Format('Applet No %d: %s / %s', [I, Name, Desc]));
49        end;
50      end;
51    finally
52      {Unload CPL}
53      FreeLibrary(H);
54    end;
55  end;
56  
57  procedure TForm1.Button1Click(Sender: TObject);
58  begin
59    ShowCPLNameAndDescription('main.cpl');
60  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC