Use Windows 7 APIs in powershell and. net
This article is a translation of the content in the powershell script blog. Original article address:
Http://blogs.technet.com/ B /heyscriptingguy/archive/2012/11/11/weekend-scripter-working-with-windows-libraries.aspx
Windows API is an interface provided by windows.
Taking the win7 library folder as an example, we can operate the win7 library by using the object methods provided in the win api.
It is better. Net is more underlying and faster.C LanguageSyntax.
[Windows 7 API code pack for Microsoft? . NET framework can be viewed as. NET Framework. . Net extension. Or a bridge.
Let's be there. . Net. Net object, method attribute method, use win api. (Instead of C syntax)
The current version is 1.1 and the size is 24 mb. The official website is:
Http://archive.msdn.microsoft.com/WindowsAPICodePack
We know that powershell is very convenient to call. Net function, and with this bridge, powershell calls win api is also simple and intuitive.
Let's take a look at what features it brings:
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
--------------------------------------------------------
Example:
# 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 ()
This example is not very good. It is recommended to modify the library folder, change the wallpaper, and other functions.
Modify the registry.
However, many of the dynamic display effects can only be achieved using APIs. The registry cannot be used.
-------------------------------------------------------