zoukankan      html  css  js  c++  java
  • Silverlight5 RC调用Win32API

    没错,如你所知,silverlight5 RC已经提供 P/Invoke 调用本机函数的支持! 一时间情绪有些激动,立即写了个小Demo测试一下效果.

    目前已经确认的是在silverlightOOB信任模式下,才可以正常调用!客户端提权需要在silverlight应用发布时进行证书签名,即可提权!

    设置OOB模式 勾选 提升信任权限.

     

    例子 1  调用windows系统提示框的例子.

    代码如下

      [DllImport("user32.dll", EntryPoint = "MessageBoxA")]
            static extern int MsgBox(int hWnd, string msg, string caption, int type);
    
    
      private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
            {
                MsgBox(0, "这就是用DllImport调用DLL弹出的提示框哦!""提示", 0x30);
               
            }

     

    例子2   让silverlight窗口保存置顶

     

            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            private static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int Width, int Height, int flags);
     
            /// <summary>
            /// 得到当前活动的窗口
            /// </summary>
            /// <returns></returns>
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            private static extern System.IntPtr GetForegroundWindow();
    
    
            private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
            {
              
                SetWindowPos(GetForegroundWindow(), -1, 0, 0, 0, 0, 1 | 2);
            }
  • 相关阅读:
    从Android源码修改cpu信息
    lintcode-->翻转字符串
    lintcode-->哈希函数
    PCP架构设计
    PCP项目立项
    linux下wc功能的简单实现
    goahead3.6.3就基本使用(后台上传信息到html页面),高手请忽略
    四则运算生成器
    快速看完软件工程教材后,我的疑惑
    软件工程学习
  • 原文地址:https://www.cnblogs.com/leischen/p/2484654.html
Copyright © 2011-2022 走看看