Tuesday, May 19, 2009

Bridging to Managed Windows 7 Development – Vista Bridge to Windows Code Pack

Kate Gregory's Blog - On Vista Bridge, Code Pack, and versions

“Some people have asked me about the purpose of Vista Bridge now that Code Pack (ok, Windows® API Code Pack for Microsoft® .NET Framework) exists. If you want to use a Vista feature (such as the power management API) you won't find them in Code Pack yet. Vista Bridge is not under active development right now, but you can download and use the wrappers to save time and effort whether you are targeting Windows 7 or Vista. …

The second question I am getting is about versions. Code Pack 0.8 (no longer available for download) was for build 7000. Code Pack 0.85 (the current version) is for the RC of Windows 7. …”

MSDN Code Gallery - Windows® API Code Pack for Microsoft® .NET Framework (v0.85)

“The Windows® API Code Pack for Microsoft® .NET Framework provides a source code library that can be used to access new Windows 7 features (and some related Windows Vista features) from managed code. These features are not available to developers today in the .NET Framework.
The features included in this version (v0.85) of the library are:

  • Support for Windows Shell namespace objects, including the new Windows 7 libraries, Known Folders and non file system containers.
  • Windows Vista and Windows 7 Task Dialogs.
  • Windows 7 Explorer Browser Control supporting both WPF and Windows Forms.
  • Support for Shell property system.
  • Helpers for Windows 7 Taskbar Jumplists, Icon Overlay and Progress bar.
  • Support for Windows Vista and Windows 7 common file dialogs, including custom file dialog controls.
  • Support for Direct3D 11.0 and DXGI 1.0/1.1 APIs.
  • Sensor Platform APIs
  • Extended Linguistic Services APIs

…”

The Windows Blog - Windows 7 Managed Code APIs

We have enabled an easy direct access to Windows 7 (and some Windows Vista) features for .NET developers. All you need to do is download Windows API Code Pack today!

As mentioned in the Windows 7 .NET Interop Sample Libraries post, most Windows 7 APIs are written in native code C, C++, and COM APIs, and have no .Net equivalents. This makes the life of managed code developers a bit hard, forcing them to create their own interoperability layers for communicating between .NET and the native Windows APIs. Some native APIs are easy to wrap and use from managed code, requiring simple interoperability efforts like adding a reference to a COM type library. However, some are extremely problematic and require a lot of knowledge about the “Win32” programming style. That is exactly why the Windows API Code Pack for Microsoft .NET Framework was created

The Windows API Code Pack (Code Pack) is much larger in terms of offered functionality and quality than its older brother, the Windows Vista Bridge. The Code Pack contains a wide variety of APIs, including very comprehensive Windows Shell namespace objects, Windows Taskbar, Libraries, and Windows 7 Extended Linguistic Services. The following is a short list of the APIs contained in the Windows API Code Pack

When you download and unzip the v0.85 file, you will find a Samples folder. This folder contains number of samples demonstrating the entire range of APIs provided by the API Code Pack. You will also find the WindowsAPICodePack folder that contains the full source code for this library. This provides a great interoperability learning opportunity, while giving you the full flexibility of changing source code.

There are many samples, 13 for now with more coming in future releases, but there are four in particular that I want to highlight.

WPF Explorer Browser Demo

untitled

Similarly, Shell Hierarchy Tree Demo, shows how you can traverse the entire computer contents using the Shell namespace starting from the topmost Desktop objects:

untitled-3

Taskbar and Libraries

untitled2

…”

Good to see this move forward and stay pretty much in sync with the Windows 7 release cycle. I do wish that something like this would be included in the OS, as it would lower the barrier to entry (but trying it to the OS also might slow its innovation?)

One note, as you might expect, the samples are all in C# [Insert comment here that it’s better to be a VB’er because we get the best of both languages… We, by necessity, need to be able to read C# well, yet get to code in VB… ;]

 

Related Past Post XRef:
Pimping your Win7 Taskbar – Extending the Win7 Taskbar with Managed Code
Vista Bridge v1.4 Released – Now with custom controls for Common File Dialogs, BreadCrumb control and Aero Glass
Vista Bridge (v1.3) available on MSDN Code Gallery
It’s the Bridge to… Vista – Getting and installing Vista Bridge Sample Library
Ease Use of Vista Task/Common Dialogs with Project Glidepath Windows Vista Bridge Package

3 comments:

Denver said...

Oops. I meant it’s a great article.

Kate Gregory said...

Actually, 0.8 is still available for download, for folks who are still on build 7000 and haven't gone to the RC yet. I updated my post with a screenshot showing where to find the link.

http://www.gregcons.com/KateBlog/OnVistaBridgeCodePackAndVersions.aspx

Kate

Greg said...

Nice! Thanks for that update... :)