K 17 dielu tipov pre Delphi dodavam: CPL aplet je mozne spustit aj programovo. (Kod treba upravit podla testov na vsetky aplety. S uvedenym kodom su pri niektorych apletoch chyby.)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TAppletDialog = function(hWndCPL : hWnd; iMEssage : integer; lParam1 : longint; lParam2 : longint):LongInt; StdCall;
TForm1 = class(TForm)
private
{ Private declarations }
public
procedure RunApplet(const S:String);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.RunApplet(const S: String);
var UniversalDialog:TAppletDialog;
hDllInst:THandle;
begin
if Length(S)>4 then
begin
hDllInst:=LoadLibrary(PChar(S));
if hDllInst<=0 then
Raise Exception.Create('Chyba '+IntToStr(GetLastError)+' pri pokuse o načítanie Control Panel Appletu.');
try
@UniversalDialog:=GetProcAddress(hDllInst, 'CPlApplet');
if not Assigned(UniversalDialog) then
WinExec(PChar('rundll32 shell32.dll,Control_RunDLL '+S+',,0'),SW_SHOW);
UniversalDialog(Application.Handle, CPL_DBLCLK, 0, 0);
finally
FreeLibrary(hDllInst);
end;
end;
end;
end.