silverlight调用vcdll

注1:为了确保silverilght5在浏览器或桌面上成功调用win32 DLL,必须在项目属性中勾选相应的权限:

  勾选Enable running application out of the browser及其Require elevated trust when running in-browser

  勾选Require elevated trust when running in-browser

  注2:win32 dll文件编译后放在\windows\system32或\windows\system目录下,win7 x64的系统放在后者。

 

///<summary>  
        /// 弹出窗口  
        ///</summary>  
        ///<param name="h">弹出窗口的父窗口,在这里没有,所以为0</param>  
        ///<param name="message">需要显示的消息</param>  
        ///<param name="title">窗口的标题</param>  
        ///<param name="type">窗口的类型 0为确定按钮,1为确定、取消双按钮</param>  
        ///<returns></returns>  
        [DllImport("user32.dll", EntryPoint = "MessageBoxA")]
        public static extern int MsgBox(int h, string message, string title, int type);

        ///<summary>  
        /// 获取到DLL的值  
        ///</summary>  
        ///<param name="Anumber">数字A</param>  
        ///<param name="Bnumber">数字B</param>  
        ///<returns></returns>  
        [DllImport("IlasLinkDll.dll", CharSet = CharSet.Ansi, EntryPoint = "GetNum", ExactSpelling = false)]
        public static extern double GetNum(double Anumber, double Bnumber); 


        public SLDllTest()
        {
            InitializeComponent();
            MsgBox(0, "调用IlasLinkDll.dll获得的结果:" + GetNum(500.0, 23.0).ToString(), "提示信息", 1);
            MsgBox(0, "这是调用User32.dll弹出的窗口", "提示信息", 1);
        }

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值