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);
            }
  • 相关阅读:
    排序应用于链表
    线性时间排序算法
    排序算法
    2017计蒜客蓝桥杯模拟赛5
    第六届河南省赛 River Crossing 简单DP
    POJ 3061 Subsequence 尺取法 POJ 3320 Jessica's Reading Problem map+set+尺取法
    天梯赛 L2-020. 功夫传人 BFS
    天梯赛 L2-019. 悄悄关注 map
    配置在Chrome,Firefox中打开
    http响应状态码大全
  • 原文地址:https://www.cnblogs.com/leischen/p/2484654.html
Copyright © 2011-2022 走看看