在powershell和.net中,使用windows7 api

來源:互聯網
上載者:User

在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實現。這種是沒法用註冊表的。
-------------------------------------------------------

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.