Last week I’ve been doing a lot of research for my Vista-development session at our local Big>Days conference. When speaking about “Vista development” you can split up the possibilities into two parts: Either managed APIs or unmanaged. Yes :-) although Vista is the first operating system released in the new “managed .NET century”, the majority of OS features were still developed in unmanaged code as C++ or C.

The managed APIs for Vista are released as Addon to .NET 2.0 called “.NET Framework 3.0” (formerly known as .NETFX) and include Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), Windows Workflow Foundation (WF), Windows Cardspace and other APIs like the new System.IO.Packaging API for OpenXML.
WAIT! …you might say – these APIs are not for Vista exclusively! You’re right :-) .NET 3.0 is also available for Windows XP SP2 and Windows Server 2003 SP1. But it was developed with Windows Vista & “Longhorn” Server in mind. That’s the reason why you can leverage it’s full power (e.g. Windows Activation Service (WAS) for WCF) only work on these two new OSes and why WPF tends to perform slightly better on those.

Besides .NET 3.0 there are thousands of new unmanaged APIs and “half-managed” APIs (Vista Sidebar Gadgets) included in Windows Vista. While .NET 3.0 is getting well known along developers, the new unmanaged APIs are not that popular. Being a C# developer I browsed around the new APIs and tried to call some of them (the nice ones :-)) out of .NET. Generally saying there are three ways of doing this – depending on the implementation of the API:

  • COM Interfaces
    These are the easiest to call. Just chose “Add Reference” in Visual Studio and a wrapper is created for the interfaces. (e.g. RSS API)
  • Win32 methods
    You can call these via P/Invoke. The problem is you have to rebuild the entire method definition and all structs with managed datatypes (which are not often so easy to match).(e.g. Restart & Recovery API)
  • VTable-based COM Interface
    These interfaces CANNOT be added as a reference as they do not have any type library. So you need to rebuild them like with P/Invoke using the [ComImport()] attribute. (with the same issues). (e.g. IPreviewHandler)
  • ShellExtensions hosted with in the explorer
    Extensions for the Windows explorer should NOT be developed with .NET! Explorer can only load one instance of the .NET CLR. So if you host .NET 1.1 and 2.0 extensions and the ones with 1.1 are loaded first, the 2.0 extensions will fail, because CLR 1.1 is loaded into the explorer. (e.g. IFilter)

For the Big>Days session I’ve tried the following APIs:

  • Restart & Recovery API (Restart & recover applications on crash or hang)
  • Windows Error Reporting (Send error reports for later inspection)
  • Restart Manager (Allows restarting running applications for updates)
  • Vista UI (TaskDialog, CommandButton)
  • PreviewHandlers (displaying file previews in Outlook and Explorer)

Besides this I’m planning to show impacts of user account control (UAC) and how to make applications UAC ready.

Andreas Rynes, who is a colleague of mine will show advanced Vista sidebar gadget development and the new RSS API and Speech API.

IMPORTANT: If you plan attending the Big>Days (or event if not :-)) give me your feedback about our plans for this session!

Next week I’ll cover details on Restart & Recovery API in a post!