調用Windows Mobile內建的控制台項

來源:互聯網
上載者:User

      如何在程式中調用Windows Mobile系統內建的控制台項呢?經常在論壇或者郵件組看到這樣的問題, 比如我們也許在自己的程式中需要添加一個“移除程式”功能,或者需要使用者佈建一下鬧鐘,或者需要修改一下其他的系統設定,這時候也許直接調用系統內建的控制台,要比自己修改註冊表自己設計訊息儲存方式自己設計UI要簡單的多。

下面這個類就實現了這一功能:

class ControlApplet{    public static void ShowApplet(AppletType applet)    {        ProcessStartInfo startInfo = new ProcessStartInfo();        startInfo.FileName = @"\Windows\ctlpnl.exe";        startInfo.Arguments = String.Format("cplmain.cpl,{0}", (byte)applet);        Process.Start(startInfo);    }    public static void ShowApplet(AppletType applet, byte tabIndex)    {        ProcessStartInfo startInfo = new ProcessStartInfo();        startInfo.FileName = @"\Windows\ctlpnl.exe";        startInfo.Arguments = String.Format("cplmain.cpl,{0},{1}", (byte)applet, tabIndex);        Process.Start(startInfo);    }    public enum AppletType    {        Contrast,        Password,        OwnerInformation,        Power,        Memory,        About,        Backlight,        AlignScreen,        InputMethod,        SoundsReminders,        RemovePrograms,        Menus,        Buttons,        TodaySettings,        PCConnections,        ModemConnections,        Clock,        NetworkConnections,        RegionalSettings    }    #region Constant Fields    public const byte CPAPPLET_OWNERINFO_IDENTIFICATION = 0;    public const byte CPAPPLET_OWNERINFO_NOTES = 1;    public const byte CPAPPLET_MEMORY_MAIN = 0;    public const byte CPAPPLET_MEMORY_RUNNINGPROGRAMS = 1;    public const byte CPAPPLET_ABOUT_VERSION = 0;    public const byte CPAPPLET_ABOUT_DEVICEID = 1;    public const byte CPAPPLET_ABOUT_COPYRIGHTS = 2;    public const byte CPAPPLET_BACKLIGHT_BATTERY = 0;    public const byte CPAPPLET_BACKLIGHT_EXTERNAL = 1;    public const byte CPAPPLET_INPUT_INPUTMEHTOD = 0;    public const byte CPAPPLET_INPUT_WORDCOMPLETION = 1;    public const byte CPAPPLET_INPUT_OPTIONS = 2;    public const byte CPAPPLET_SNDANDREMINDERS_VOLUME = 0;    public const byte CPAPPLET_SNDANDREMINDERS_SOUNDS = 1;    public const byte CPAPPLET_SNDANDREMINDERS_REMINDERS = 2;    public const byte CPAPPLET_MENUS_STARTMENU = 0;    public const byte CPAPPLET_MENUS_NEWMENU = 1;    public const byte CPAPPLET_BUTTONS_PROGRAMBUTTONS = 0;    public const byte CPAPPLET_BUTTONS_UPDOWNCONTROL = 1;    public const byte CPAPPLET_MODEM_CONNECTIONS = 0;    public const byte CPAPPLET_MODEM_DIALING = 1;    public const byte CPAPPLET_CLOCK_TIME = 0;    public const byte CPAPPLET_CLOCK_ALARMS = 1;    public const byte CPAPPLET_RS_REGION = 0;    public const byte CPAPPLET_RS_NUMBER = 1;    public const byte CPAPPLET_RS_CURRENCY = 2;    public const byte CPAPPLET_RS_TIME = 3;    public const byte CPAPPLET_RS_DATE = 4;    #endregion}

簡單來說就是啟動ctlpnl.exe,並傳入相應的參數即可,注意第一個參數是表示控制台的哪一項,第二個參數(如果有的話)是表示控制台項目的具體哪個標籤頁,它為空白時預設為第一個標籤頁。使用的時候如下:

ControlApplet.ShowApplet(ControlApplet.AppletType.Clock);

效果:

ControlApplet.ShowApplet(ControlApplet.AppletType.Clock,ControlApplet.CPAPPLET_CLOCK_ALARMS);

效果:

完整樣本在這裡下載:

http://files.cnblogs.com/fox23/ControlPanelSample.rar

Enjoy!

相關資料:

Show Control Panel Programmatically

http://www.pocketpcdn.com/articles/controlpanel.html

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.