惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google Online Security Blog
Google Online Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
Cisco Talos Blog
Cisco Talos Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Scott Helme
Scott Helme
Project Zero
Project Zero
E
Exploit-DB.com RSS Feed
S
Secure Thoughts
K
Kaspersky official blog
L
Lohrmann on Cybersecurity
NISL@THU
NISL@THU
WordPress大学
WordPress大学
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LINUX DO - 热门话题
小众软件
小众软件
P
Privacy & Cybersecurity Law Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
About on SuperTechFans
Hacker News: Ask HN
Hacker News: Ask HN
AWS News Blog
AWS News Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hacker News: Front Page
F
Full Disclosure
Latest news
Latest news
Schneier on Security
Schneier on Security
The Hacker News
The Hacker News
T
Troy Hunt's Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Jina AI
Jina AI
Martin Fowler
Martin Fowler
P
Proofpoint News Feed
TaoSecurity Blog
TaoSecurity Blog
G
GRAHAM CLULEY
Forbes - Security
Forbes - Security
V
V2EX - 技术
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Vulnerabilities – Threatpost
C
Cyber Attacks, Cyber Crime and Cyber Security
MongoDB | Blog
MongoDB | Blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
P
Privacy International News Feed
C
Check Point Blog
N
News and Events Feed by Topic

博客园 - davin

Beginning Asp.Net Security 读书笔记-----XSS phonegap3.0+HTMLl5 开发 ipad app 总结 移动支付-修复FireFox在android移动设备下面的Session 丢失的问题 Window.history.forward(1) 阻止页面后退详解 Pro WPF and Silverlight MVVM:第5章 Event and Command 读书笔记 Pro WPF and Silverlight MVVM 第4章ViewModel 读书笔记 Silverlight4:Devexpress Report Useful rules for compatible with FF,safari and ie8 Entity Framework 4.0 FK Properties && FK Associations Entity Framework 4.0 recipes 读书笔记2 ExecuteStoreQuery() Entity Framework 4.0 Recipes 读书笔记1 EDM中的 Complex Type sqlserver2008 + team foundation server 2008 sp1 silverlight animation 读书笔记(4)三角函数 silverlight animation 读书笔记(3)坐标与向量 silverlight animation 读书笔记<2>模糊, 裁剪,拖拽 foundation silverligh3 animation 读书笔记<1>transform Entity Framework object && Json 序列化的问题 silverlight3:(ItemControl 的)UI Virtualization SharpZipLib 数据压缩
在silverlight中打开调用外部程序的几种方式
davin · 2010-08-15 · via 博客园 - davin

在silverlight中调用外部程序的几种方法总结如下:

1.silverlight不支持oob模式的时候,silverlight调外部应用程序只能通过activex来实现。

   大致方法如下,之前写的一个:

       var idropItems;
        var clsid;
        var plugin;
        var currentDivIndex;
        jQuery(document).ready(function() {
            idropItems = window.parent.GetIDropItems();
            if (idropItems.length > 0) {

                BuildDivContainer();

                //activex的clsid,

                clsid = "clsid:21E0CB95-1198-4945-A3D2-4BF804295F78";
                $("#Pagination").pagination(idropItems.length, {
                    num_edge_entries: 2,
                    num_display_entries: 8,
                    items_per_page: 8,
                    next_text: "",
                    prev_text: "",
                    callback: pageselectCallback
                });
            }
        });
        function pageselectCallback(page_id, jq) {
            BuildIDropItems(page_id);
        }

   function BuildIDropItems(pageIndex) {

            $("#c_" + currentDivIndex).hide();
            if ($("#c_" + pageIndex).attr("loaded") == "0") {
                var itemIndex = pageIndex * 8;
                var html = "";
                for (var i = itemIndex; i < itemIndex + 8; i++) {
                    if (i < idropItems.length) {
                        if (idropItems[i].ObjectType == '2') {
                            var objectName = GetSubstring(idropItems[i].ObjectName.substring(0, idropItems[i].ObjectName.lastIndexOf('.')), 13);
                            var ext = idropItems[i].ObjectName.substring(idropItems[i].ObjectName.lastIndexOf('.') + 1).toLowerCase();
                                                         html += "<div class='ItemBox'>";
                                html += "<object classid='" + clsid + "' width='101' height='101' >";
                                html += "<param name='background' value=''>";
                                html += "<param name='proxyrect' value='0, 0, 101, 101'>";
                                html += "<param name='griprect' value='0, 0, 101, 101'>";
                                html += "<param name='package'  value='GetIDropItem.aspx?guid=" + idropItems[i].ObjectId + "&type=xml'>";
                                html += "<param name='validate' value='1'>";
                                html += "<img src='GetIDropItemguid=" + idropItems[i].ObjectId + ".img' title= />";
                                html += "</object>";
                                html += "<span class='ItemName'>" + objectName + "</span>";
                                html += "</div>";                                      

                        }
                    }
                }
                $("#c_" + pageIndex).html(html).attr("loaded", "1");
            }
            $("#c_" + pageIndex).show();
            currentDivIndex = pageIndex;
        }

2.在silverlight4里面,可以在oob模式下可以直接调com组件,如下面代码段:就是通过AutomationFactory调用dt930的com组件
      if (Application.Current.InstallState != InstallState.Installed)
          Application.Current.Install();

      //oob模式,需要提升权限
      if (Application.Current.HasElevatedPermissions && System.Windows.Interop.ComAutomationFactory.IsAvailable)
       {

          ///AutomationFactory call com componnnet          
            dynamic dt = AutomationFactory.CreateObject("DT390COM.DT390");

      }
需引用下面的命名空间

using System.Dynamic;

using System.Windows.Interop;
using System.Runtime.InteropServices.Automation;

3.上面2种方法都要求调用的外部程序是com组件,如果不是com组件,又该如何去启动外部程序呢.通过使用WScript.Shell 组件可以打开任何的应用程序

  eg  using (dynamic shell = AutomationFactory.CreateObject("WScript.Shell"))
         {
                shell.Run(@"C:\windows\notepad.exe"); //you can open anything
               shell.SendKeys(txtTextToSend.Text);
               
          }

  除此之外还可以在js中调用

      <javascript language="javascipt">{

       var shell = new ActiveXObject("WScript.shell");

       shell.Run(@"C:\windows\notepad.exe");

    }