• 在powershell和.net中,使用windows7 api


    在powershell和.net中,使用windows7 api

    本篇是翻译整理 powershell脚本小子博客中的内容。原文地址:
    http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/11/weekend-scripter-working-with-windows-libraries.aspx


    windows  api 是win操作系统提供的接口。
    以win7库文件夹为例,我们使用win api中提供的对象方法等,就可以操作win7的库。
    它比。net更底层,速度更快,使用的是c语言语法。
    而【Windows 7 API Code Pack for Microsoft? .NET Framework】可以看作是。net的扩展。或者说是桥梁。
    让我们在。net中,用。net对象,方法属性的方式,使用win api。(而不是c语法)
    当前版本是1.1,大小为24MB,官网是:
    http://archive.msdn.microsoft.com/WindowsAPICodePack


    我们知道,powershell是很方便调用。net功能的,而有了这个桥梁,powershell调用win api 也简单直观起来了。

    下面我们来看看,它带来了什么功能:
    Windows 7 Taskbar
         Jump Lists, Icon Overlay, Progress Bar, Tabbed Thumbnails, and Thumbnail Toolbars
    Windows Shell
         Windows 7 Libraries
         Windows Shell Search API support
         Explorer Browser Control
         A hierarchy of Shell Namespace entities
         Windows Shell property system
         Drag and Drop for Shell Objects
         Windows Vista and Windows 7 Common File Dialogs, including custom controls
         Known Folders and non-file system containers
         Shell Object Watcher
         Shell Extensions API support
    DirectX
         Direct3D 11.0, Direct3D 10.1/10.0, DXGI 1.0/1.1, Direct2D 1.0, DirectWrite, Windows Imaging Component (WIC) APIs
    Windows Vista and Windows 7 Task Dialogs
    Sensor Platform APIs
    Extended Linguistic Services APIs
    Power Management APIs
    Application Restart and Recovery APIs
    Network List Manager APIs
    Command Link control and System defined Shell icons


    --------------------------------------------------------
    例子:
     # Create a PowerShell Library and include corresponding folders
    Add-type -path Microsoft.WindowsAPICodePack.Shell.dll
    $ps = New-Object Microsoft.WindowsAPICodePack.Shell.ShellLibrary –Argument "PowerShell",$true
    $ps.Add("$($env:userprofile)\Skydrive\PowerShell")
    $ps.Add("$($env:userprofile)\SkydrivePro\PowerShell")
    $ps.Close()

    这个例子其实并不是很好,修改库文件夹,更换壁纸等功能,推荐通过
    修改注册表的方法来实现。
    不过,很多显示时的动态效果,只能用api实现。这种是没法用注册表的。
    -------------------------------------------------------

  • 相关阅读:
    C#输出JS代码封装类Alart
    我的汇编学习之路(2)win8(64位)下安装debug
    .NET使用一般处理程序生成验证码
    ?运算符(null合并运算符)和三木运算符
    讲解:小菜鸟自制的.NET实体类生成器
    我的汇编学习之路(1)进制转换
    未来
    callee,caller区别
    string::size_type
    ubuntu 12.04 LTS u盘安装
  • 原文地址:https://www.cnblogs.com/piapia/p/2768148.html
Copyright © 2020-2023  润新知