在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实现。这种是没法用注册表的。
-------------------------------------------------------
posted on 2012-11-13 15:44 PowerShell免费软件 阅读(818) 评论(0) 编辑 收藏 举报
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端