zoukankan      html  css  js  c++  java
  • C# 获取系统安装程序列表及卸载程序

           首先添加引用Microsoft.WindowsMobile.Configuration。往界面中拖入控件ListBox,
           下面为部分代码:

           

    代码
    private XmlDocument doc;

            
    /// <summary>
            
    /// 列出PDA上已安装的程序
            
    /// </summary>
            
    /// <param name="lb">待填充列表</param>
            private void ListApps(ListBox lb)
            {
                doc 
    = new XmlDocument();
                
    //具体原理还要学习下
                doc.LoadXml(@"<wap-provisioningdoc><characteristic-query 

    type=""UnInstall"" /></wap-provisioningdoc>
    ");
                XmlDocument ret 
    = ConfigurationManager.ProcessConfiguration(doc, 

    true);
                XmlNodeList list 
    = ret.SelectNodes("//characteristic/characteristic");
                lb.Items.Clear();
                lb.SuspendLayout();
                
    foreach (XmlNode xn in list)
                {
                    lb.Items.Add(xn.Attributes[
    "type"].Value);
                }
                lb.ResumeLayout(
    false);
            }


            
    /// <summary>
            
    /// 对选中的程序卸载
            
    /// </summary>
            
    /// <param name="appName">程序名</param>
            private void UnInstall(string appName)
            {
                Cursor.Current 
    = Cursors.WaitCursor;
                doc 
    = new XmlDocument();
                
    string xml = @"
                <wap-provisioningdoc>
                    <characteristic type=""UnInstall"" >
                        <characteristic type=""{0}"" >
                            <parm name=""uninstall"" value=""1"" />
                        </characteristic>
                    </characteristic>
                </wap-provisioningdoc>
    ";
                doc.LoadXml(
    string.Format(xml, appName));
                ConfigurationManager.ProcessConfiguration(doc,
    true);
                ListApps(listBox1);
                Cursor.Current 
    = Cursors.Default;
            }

    其实也可以用列举windows\AppMgr下的所有文件夹名(除Install文件夹外),自己测

    试了下,感觉有可行性。

  • 相关阅读:
    谈谈团队文化
    ubifs性能优化分析
    ubifs总体设计分析
    分层网络模型(二)
    哎,老了之display-box
    http协议
    box-shadow,text-shadow
    nth-child,nth-last-child,after,before,tab-highlight-color,first-child,last-child
    转载之html特殊字符的html,js,css写法汇总
    一天学习一点之express demo
  • 原文地址:https://www.cnblogs.com/MyLucifer/p/1635121.html
Copyright © 2011-2022 走看看