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.

In the Windows 7 .NET Interop Sample Libraries post, we highlighted few samples codes showing how to access the Taskbar, Libraries, Sensor, and multi-touch from .NET, and we also promised to report in the near future on a new project, Windows API Code Pack for Microsoft .NET Framework. The Windows SDK team built the Windows API Code Pack to provide easy access to Windows 7 features for .NET developers , lowering the bar for developers who want to target Windows 7 Client applications. Basically, it is the closest thing a .NET developer will have to managed code APIs for Windows 7.

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:

  • Support for Windows Shell namespace objects, including:
    • Windows 7 libraries
    • Known Folders
    • Non-file system containers
  • Windows Vista and Windows 7 Task Dialogs
  • Support for Windows 7 Explorer Browser Control
  • Support for Shell property system
  • Windows 7 Taskbar
  • 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

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

Before going into details about this demo, let’s talk about the Windows Shell. The Windows Shell is the main area of user interaction in Windows. Many users refer to the Windows Explorer as “Windows”; however, it is just one part of the overall Windows Shell. The shell includes many other UI elements, such as the Taskbar, the Start Menu, Windows Explorer windows, the Recycle Bin, and search results. The most common and well known shell objects are files and folders. However, there are many other virtual objects such as the Recycle Bin, printers, Libraries, etc. Shell objects are organized into a hierarchical namespace that encompasses the file system namespace.

With a proper understanding of the Shell namespace, and access to the topmost Shell Object, the Desktop, you can traverse the entire computer, including files and folders, as well as printers, fonts, Program files, and Recorded TV. By using the Shell namespace, developers can access all the files and folders and all the Known Folders (which we briefly mentioned in the Libraries Under the Hood post) in a given computer.

Up until now, this was blocked from .Net developers; however, the new Code Pack provides an Explorer Browser control as well as well the defined objects, structs, and APIs needed to traverse the Shell namespace. In the Shell part of the Code Pack (Shell project), you can find Explorer Browser controls for WPF and WinForms, as well as all the functionality needed to work with Known Folders, and a wide range of Shell objects (under the Common folder) such as ShellObject, ShellLink, ShellFolder, ShellItem, ShellCollection, ShellThumbnail, and the list continues. The Taskbar and Libraries implementation also uses many of these shell objects. As shown in the following picture, the Explorer Browser demo spotlights the Explorer Browser control that can help visualize the Shell namespace.

image

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

image

Sensors

The Code Pack also contains Sensor APIs for the Windows 7 Sensor and Location platform. The Sensor project contains all the necessary definitions to work with Sensors including a SensorManager to get sensors, and a Sensor class to work with sensors, and of course a SensorReport that allows you to access the sensor data. The Sensor demos include two demos illustrating two sensors, Light and Motion. You can use the Virtual Light Sensor from Win 7 RC SDK to simulate different lighting conditions, and the very simple Ambient Light Level application to display a visual representation of the total amount of light detected by the light sensor.

image

Extended Linguistic Services Demo

Extended Linguistic Services (ELS) is another very interesting technology available in Windows 7. ELS is a new feature in Windows 7 that allows developers to use the same small set of APIs to leverage a variety of advanced linguistic functions. By using ELS APIs in Windows 7, developers can auto-detect the language of any piece of Unicode text and use that information to make smarter user experience choices for customers around the world. The ELS platform is the interface between your application and ELS services. It provides a simple way to leverage several kinds of linguistic functionality through the same API, which allows the application to access and use specific services. For more information about the API, see Extended Linguistic Services Reference.

By using the MappingAvailableServices class you can query a given string for the language in which the string is written. This allows you to either verify the language in which a string is written or ask in what language a string is written. This can be a very powerful tool for multi-language application developers.

And it is easy to use. For example, the following line of code tries to detect what languages are used in the string:

scriptDetection.RecognizeText("This is English. АБВГД.", null))

The output will be something like:

Recognized 2 script ranges

Range from 0 to 16, script Latn

Range from 17 to 22, script Cyrl

Taskbar and Libraries

The Code Pack provides the required APIs to program against the Taskbar and Libraries in Windows 7. For the Taskbar you can:

  • Create and manipulate JumpLists, including tasks and items
  • Display Dynamic Overlay Icons, Thumbnail Toolbars
  • Use the Taskbar progress bar

At this stage of the development, you cannot Control Custom Thumbnail Preview, and custom Preview, also known as AeroPeek. To have this functionality, you will need to use the Windows 7 Taskbar Sample .NET Interop Library.

With the Taskbar demo, you can learn how to have full control over your Jump List as shown in the next image:

image

The Code Pack also provides full support for Windows 7 Libraries, which we will talk about extensively in the next post.

Please note that this library is currently a work-in-progress and this is version 0.85 of this library. The final version of this library will be available around the time of the Windows 7 RTM release. Please help us improve by downloading the source code and sample, and using them in your applications. Please report bugs or any other comments and ideas you might have using the Discussion, and Issue Tracker.


Comments

  1. Posted on: June 06, 2009 at 1:30PM  

    www.windows7taskforce.com/.../1811

    [suggestion #1] keep Menu color layout consistency for Windows 7

    Problem:

    1)

    to improve Appliaction Menu color. (discriminated Appliaction Menu color very difficult, looked vague.)

    There is no consistency between the Start Menu and the Appliaction Menu.

    To keep Start Menu and Appliaction Menu color style consistency, like Windows XP.

    2)

    Windiows Explorer Menu has 2 color layout styles in Windows7.

    Please keep color layout consistency for Menu.

    Why the 'Include in libary' used another color layout?

    Solution:

    keep Menu color layout consistency for Windows 7

    view screenshot:

    www.windows7taskforce.com/.../560

    ------------------------------------------------------

    www.windows7taskforce.com/.../1648

    [suggestion #2] keep Details Columns style consistency for Windows 7

    Problem:

    Details Columns has 2 styles in Windows7.

    Please keep style consistency for Details Columns.

    Solution:

    keep Details Columns style consistency

    view screenshot:

    www.windows7taskforce.com/.../560

    ------------------------------------------------------

    www.windows7taskforce.com/.../1622

    [suggestion #3] keep UI theme style consistency for Windows 7

    Problem:

    keep UI theme style consistency for Menu bar & Tool bar.

    like Windows XP theme style's consistency.

    Solution:

    keep UI theme style consistency for Windows 7.

    view snapshot:

    www.windows7taskforce.com/.../700

    ------------------------------------------------------

    www.windows7taskforce.com/.../2095

    [suggestion #4] improve color layout for currently using task icon

    Problem:

    Taskbar color layout too bad.

    If you using light color desktop background, you will don't know what is the using task icon.

    Its brightness too high, so looks too blurred when light color desktop background.

    Currently using task icon is recognize hard when light color desktop background.

    Solution:

    improve color layout for currently using task icon

    view snapshot:

    www.windows7taskforce.com/.../560

  2. Posted on: June 06, 2009 at 1:33PM  

    [suggestion #10] bootscreen delete "Starting Windows" text for other language

    Problem:

    If you use Japanese / Chinese / Korean / Thai / Other Language.

    In FULLSCREEN look bootscreen, the other language "Starting Windows" text very big, very ugly.

    Solution:

    bootscreen remove "Starting Windows" text for other language

    view snapshot:

    www.windows7taskforce.com/.../560

    -----------------------------------------------

    [suggestion #11] Windows Journal update to Ribbon-based UI

    Problem:

    Bill Gates say: We'll Use the Ribbon/Fluent User Interface across Windows 7.

    But why only the Paint and WordPad?

    He forget Windows Journal and some application.

    Solution:

    Windows Journal update to Ribbon-based UI

    view snapshot:

    www.windows7taskforce.com/.../560

    -----------------------------------------------

    [suggestion #12] Windows PowerShell ISE update to Ribbon-based UI

    Problem:

    Bill Gates say: We'll Use the Ribbon/Fluent User Interface across Windows 7.

    But why only the Paint and WordPad?

    He forget Windows PowerShell ISE and some application.

    Solution:

    Windows PowerShell ISE update to Ribbon-based UI

    view snapshot:

    www.windows7taskforce.com/.../560

    -----------------------------------------------

    www.windows7taskforce.com/.../1579

    [suggestion #13] Windows Photo Viewer support GIF, MNG format

    Problem:

    1. Windows Photo Viewer can't open .GIF, MNG, APNG format

    2. IE8 can't open MNG, APNG format

    Solution:

    support required

    GIF en.wikipedia.org/.../Graphics_Interchange_Format

    MNG en.wikipedia.org/.../Multiple-image_Network_Graphics

    APNG en.wikipedia.org/.../Animated_Portable_Network_Graphics

  3. Posted on: June 11, 2009 at 7:26PM  

    Check out the new version at

    code.msdn.microsoft.com/WindowsAPICodePack

  4. Posted on: June 11, 2009 at 7:29PM  

    Check out the new version of the code pack at code.msdn.microsoft.com/WindowsAPICodePack

Trackbacks

  1. Posted by: bWindows 7/b Managed Code APIs - bWindows 7/b for Developers - The b…/b « Windows 7 Live Info on May 19, 2009 at 1:19AM

    Pingback from  bWindows 7/b Managed Code APIs - bWindows 7/b for Developers - The b…/b «  Windows 7 Live Info

  2. Posted by: progg.ru on May 19, 2009 at 2:02AM

    Thank you for submitting this cool story - Trackback from progg.ru

  3. Posted by: Windows 7 Managed Code APIs - Windows 7 for Developers - The … « ?????? THe World on May 19, 2009 at 3:55AM

    Pingback from  Windows 7 Managed Code APIs - Windows 7 for Developers - The … «  ?????? THe World

  4. Posted by: Mungkee » Blog Archive » Windows 7 Managed Code APIs - Windows 7 for Developers - The … on May 19, 2009 at 7:20AM

    Pingback from  Mungkee  » Blog Archive   » Windows 7 Managed Code APIs - Windows 7 for Developers - The …

  5. Posted by: Dew Drop - May 19, 2009 | Alvin Ashcraft's Morning Dew on May 19, 2009 at 8:00AM

    Pingback from  Dew Drop - May 19, 2009 | Alvin Ashcraft's Morning Dew

  6. Posted by: TheUndeadable entwickelt on May 19, 2009 at 10:23AM

    Da Großteile der neuen Windows 7-APIs in C++ geschrieben worden sind und nicht direkt für .Net zur Verfügung steht, hat Microsoft einen kleinen Wrapper geschrieben, der die unmanaged C++-APIs in eine .Net-API bringt: Windows API Code Pack Scheinbar wird

  7. Posted by: Sensor and Location .NET Library for Windows 7 | CHARGED's Digital Lifestyle at Work or Play on May 19, 2009 at 12:06PM

    Pingback from  Sensor and Location .NET Library for Windows 7 | CHARGED's Digital Lifestyle at Work or Play

  8. Posted by: ComponentGear.com Feed on May 19, 2009 at 12:16PM

    Windows 7 includes unique features that can really light up your application and create new possibilities

  9. Posted by: Sensor and Location .NET Library for Windows 7 | Tech-monkey.info Blogs on May 19, 2009 at 12:23PM

    Pingback from  Sensor and Location .NET Library for Windows 7 | Tech-monkey.info Blogs

  10. Posted by: Windows 7 Managed Code APIs - Windows 7 for Developers - The … | Current Technology Updates daily on May 19, 2009 at 1:36PM

    Pingback from  Windows 7 Managed Code APIs - Windows 7 for Developers - The … | Current Technology Updates daily

  11. Posted by: Windows 7 Managed Code APIs | Switch on the Code on May 19, 2009 at 3:01PM

    Pingback from  Windows 7 Managed Code APIs | Switch on the Code

  12. Posted by: Windows 7 Managed Code APIs - Windows 7 for Developers - The … | DONG'S BLOG on May 19, 2009 at 3:04PM

    Pingback from  Windows 7 Managed Code APIs - Windows 7 for Developers - The … | DONG'S BLOG

  13. Posted by: Antonio on May 19, 2009 at 3:18PM
  14. Posted by: Geoffrey Emery on May 19, 2009 at 3:40PM

    Managed .net API for Sensor and GPS in windows 7 So Cool!

  15. Posted by: Sensor and Location .NET Library for Windows 7 | Breaking News | Latest News | Current News on May 19, 2009 at 4:27PM

    Pingback from  Sensor and Location .NET Library for Windows 7 | Breaking News | Latest News | Current News

  16. Posted by: Tech News, Resources from Blogosphere - 20 May 09(5) | Best Webhosting on May 19, 2009 at 10:32PM

    Pingback from  Tech News, Resources from Blogosphere - 20 May 09(5) | Best Webhosting

  17. Posted by: Windows 7 Managed Code APIs through the “Windows API Code Pack” « {Programming} & Life on May 20, 2009 at 1:16AM

    Pingback from  Windows 7 Managed Code APIs through the “Windows API Code Pack” « {Programming} & Life

  18. Posted by: Windows 7 Managed Code APIs | Blog on May 20, 2009 at 10:37PM

    Pingback from  Windows 7 Managed Code APIs | Blog

  19. Posted by: Taskbar and Libraries .NET Library for Windows 7 | CHARGED's Digital Lifestyle at Work or Play on May 22, 2009 at 10:36AM

    Pingback from  Taskbar and Libraries .NET Library for Windows 7 | CHARGED's Digital Lifestyle at Work or Play

  20. Posted by: ComponentGear.com Feed on May 22, 2009 at 10:47AM

    Yochay Kiraity has been working with the team to create Managed Code APIs making it even easier for

  21. Posted by: Taskbar and Libraries .NET Library for Windows 7 | Tech-monkey.info Blogs on May 22, 2009 at 11:00AM

    Pingback from  Taskbar and Libraries .NET Library for Windows 7 | Tech-monkey.info Blogs

  22. Posted by: Multi-touch .NET Library for Windows 7 | CHARGED's Digital Lifestyle at Work or Play on May 22, 2009 at 1:21PM

    Pingback from  Multi-touch .NET Library for Windows 7 | CHARGED's Digital Lifestyle at Work or Play

  23. Posted by: ComponentGear.com Feed on May 22, 2009 at 1:28PM

    Yochay Kiraity has been working with the team to create Managed Code APIs making it even easier for

  24. Posted by: .NET Library for Windows 7 « vincenthome’s Tech Clips on May 22, 2009 at 2:52PM

    Pingback from  .NET Library for Windows 7 « vincenthome’s Tech Clips

  25. Posted by: ComponentGear.com Feed on May 22, 2009 at 9:20PM

    This week on Channel 9, Dan and Brian discuss the top developer news, including: - Visual Studio 2010

  26. Posted by: This Week on C9: VS 2010 Beta 1, Windows API Code Pack, & a WPF Jukebox | Tech-monkey.info Blogs on May 22, 2009 at 9:49PM

    Pingback from  This Week on C9: VS 2010 Beta 1, Windows API Code Pack, & a WPF Jukebox | Tech-monkey.info Blogs

  27. Posted by: Windows 7 Managed Code APIs|Join Our Story!|AngNetwork Blog on May 22, 2009 at 11:12PM

    Pingback from  Windows 7 Managed Code APIs|Join Our Story!|AngNetwork Blog

  28. Posted by: Windows 7 Managed Code APIs - Windows 7 for Developers - The … - Windows 7 Latest News on May 24, 2009 at 2:09PM

    Pingback from  Windows 7 Managed Code APIs - Windows 7 for Developers - The … - Windows 7 Latest News

  29. Posted by: IT Digest » Windows 7 Managed Code APIs on May 25, 2009 at 2:16AM

    Pingback from  IT Digest » Windows 7 Managed Code APIs

  30. Posted by: on May 25, 2009 at 4:55AM

    又调通了一个SDK中的程序。其实就是增加了Includes和Lib的路径。汗颜。这个程序可以同时缩放2个矩形。

  31. Posted by: Windows 7 Managed Code APIs - By Egidijus Baranauskas - Post - Windows, Technology, Computers, Software News - WinSoftNews on May 25, 2009 at 6:45PM

    Pingback from  Windows 7 Managed Code APIs - By Egidijus Baranauskas - Post - Windows, Technology, Computers, Software News - WinSoftNews

  32. Posted by: Thomas Rosenstein on May 26, 2009 at 12:33AM

    Heute hab ich zufällig eine neue Version der Windows7IntegrationLibrary_Taskbar_Libraries gefunden

  33. Posted by: Managed DX - deprecated or supported? | keyongtech on May 26, 2009 at 5:00PM

    Pingback from  Managed DX - deprecated or supported? | keyongtech

  34. Posted by: Micha?? Jask??lski » Zarz??dzalne API Windows 7 (i Vista) on May 27, 2009 at 1:37AM

    Pingback from  Micha?? Jask??lski » Zarz??dzalne API Windows 7 (i Vista)

  35. Posted by: Maybe if this title is witty enough... on May 27, 2009 at 4:09PM

    Jay Wren told me yesterday about the Windows 7 managed API code pack that Microsoft has released. I spent

  36. Posted by: US ISV Developer Evangelism Team on May 28, 2009 at 4:19PM

    The Windows API Code Pack for Microsoft .NET Framework (formerly VistaBridge) is a source code library

  37. Posted by: SKOROZSI.NET on May 29, 2009 at 3:53PM

    links for 2009-05-29

  38. Posted by: Let?s talk about Windows 7 Starter on May 29, 2009 at 5:37PM

    Pingback from  Let?s talk about Windows 7 Starter

  39. Posted by: Window’s seven maneged code AIP’s « IT Welt on May 30, 2009 at 8:02PM

    Pingback from  Window’s seven maneged code AIP’s «  IT Welt

  40. Posted by: links for 2009-05-31 on May 31, 2009 at 11:53PM

    Pingback from  links for 2009-05-31