首页  编辑  

运行控制面板CPL文件

Tags: /超级猛料/OS.操作系统/Control Panel.控制面板/   Date Created:

运行控制面板CPL文件

procedure ShowControlPanelItem(Handle: Longint; CPLFile: string;

  ItemID: Longint = 0);

type

  CPLFunc = function(HwndCPI: LongInt; uMsg: Word; lParam1:

    LongInt; lParam2: Longint): LongInt; stdcall;

var

  LibInst: Longint;

  EntryPoint: Pointer;

  ItemCount: Longint;

  Info: TCPLInfo;

begin

  LibInst := LoadLibrary(PChar(CPLFile));

  try

    if LibInst <> 0 then

    begin

      EntryPoint := GetProcAddress(LibInst, 'CPlApplet');

      if Assigned(EntryPoint) then

      begin

        if TCPLApplet(EntryPoint)(Handle, CPL_INIT, 0, 0) <> 0 then

        begin

          ItemCount := TCPLApplet(EntryPoint)(Handle, CPL_GETCOUNT,

            0, 0) -1;

          if ItemID > ITemCount then

            raise Exception.Create('Could not find Item');

          TCPLApplet(EntryPoint)(Handle, CPL_INQUIRE,

            ItemID, Longint(@Info));

          TCplApplet(EntryPoint)(Handle, CPL_DBLCLK, ItemID, info.lData);

        end;

        TCPLApplet(EntryPoint)(Handle, CPL_EXIT, 0, 0);

      end;

    end;

  finally

    if LibInst <> 0 then

      FreeLibrary(LibInst);

  end;

end;

Below are some listings, these show the parameters needed to load some

of the

more commonly known applets.  To add extra value to a lot of applications,

without reinventing the wheel, any Control Panel applet can be show modally

using the code in this article.

Date Time Settings

ShowControlPanelItem(Handle, 'timedate.cpl');

System Properties

ShowControlPanelItem(Handle, 'sysdm.cpl');

ODBC Data Source Administration

ShowControlPanelItem(Handle, 'odbccp32.cpl');

Regional Settings Properties

ShowControlPanelItem(Handle, 'intl.cpl');

Add/Remove Program Properties

ShowControlPanelItem(Handle, 'appwiz.cpl');

Display Properties

ShowControlPanelItem(Handle, 'desk.cpl');

Telephony:  'Telephon.cpl'