Search Wiki:

Windows® API Code Pack for Microsoft® .NET Framework provides a source code library that can be used to access some features of Windows 7 and Windows Vista from managed code. These Windows features are not available to developers today in the .NET Framework.

The individual features supported in this version (v1.0.1) of the library are:
  • 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
  • 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

What’s New in this update (v1.0.1):
The enhancements in this update of Code Pack are:
  • Bug fixes in various features and samples included in V1.0
  • Performance improvements in Taskbar Thumbnails and Tabbed Thumbnails screen capture utility
  • A new method in Taskbar feature to enable clearing the Thumbnail clip rectangle
  • New classes and APIs in DirectWrite and Direct2D to support glyph-runs
  • Additional samples for Aero Glass and Common File Dialog
  • Documentation updates in various areas including the addition of missing Direct2D documentation

Requirements:
  • Minimum .NET Framework version required to use this library is 3.5 SP1.
  • This library targets the Windows 7 RTM version, though many of the features will work on Windows Vista as well.
  • DirectX features require Windows SDK for Windows 7 RTM. Additionally, some Direct3D samples require the August 2009 release of DirectX SDK.

Building and using the Library:
  • To build the library (except the DirectX related features) in Visual Studio 2008, please extract the contents of the ‘WindowsAPICodePack.zip’ file in a new folder and build the included ‘WindowsAPICodePack.sln’ file.
  • To build the DirectX features, build the 'DirectX.sln' file inside the DirectX directory. Additional information on using the DirectX features of the Code Pack can be found in the 'DirectXCodePack_Requirements.htm' document available as a separate download.

Samples:
The Code Pack also contains sample applications built using this library. Each sample has a C# version and a VB.NET version and has its own solution file.

Documentation:
The Code Pack also includes API reference documentation. API documentation files can be found in two separate files WindowsAPICodePackHelp and DirectXCodePackHelp in the download section.


Some relevant blog entries:

Videos:
Two minute videos demonstrating some features in this release:


Note:
Some users may experience a security related issue when opening the help files or the Visual Studio solution. Contents of help files may not be visible or a security warning similar to “Unknown Publisher” or “This file came from another computer and might be blocked” may pop up. If that happens, the user won't be able to load the solution projects because Windows will block it.

To fix this error, please unblock the help files and zip file before extracting it (right click the file | select properties | click Unblock button).

Last edited Nov 18 2009 at 10:36 PM  by sumitmsft, version 45
Comments
SBussinger wrote  May 1 2009 at 11:35 PM  
Thanks for putting this up! I'd love to see you write some support for the new Windows 7 API for the Windows Biometric Framework.

onoj wrote  May 8 2009 at 6:15 PM  
hi SBussinger. Check out Dan Griffins biometric sample for info on how to call the Biometrics Framework: http://www.jwsecure.com/dan/2009/02/17/new-test-devices-for-biometrics-project/

Octavio wrote  May 10 2009 at 7:31 AM  
Does this release include (or will include) support for multi-touch features?

sumitmsft wrote  May 14 2009 at 10:18 PM  
Multi-touch features are not likely to be included in this release of Windows API CodePack.

sandit27 wrote  May 19 2009 at 11:43 AM  
Thanks for this release..

wayne_p wrote  May 24 2009 at 12:33 AM  
Will these become a part of .NET Framework 4.0? If not, at what point will they be added?

RichardDeeming wrote  May 26 2009 at 1:52 PM  
It would be nice if the documentation included information about the minimum supported version of Windows for each feature, and some idea of how the API will fail on an unsupported platform.

mfc_97 wrote  May 27 2009 at 7:47 AM  
Thanks for this effort! Are we going to see the new DirectX features, d2d and direct text ?

xyzzer wrote  Jun 12 2009 at 3:44 PM  
D2D 1.0 and DirectWrite support are there in the new release!

devDept wrote  Jun 23 2009 at 10:07 AM  
Does this mean we can use Direct3D with managed code? As we did with DirectX 9 and Managed Direct3D? Thanks.

xyzzer wrote  Jun 24 2009 at 2:39 PM  
Yes!

RyGuy12 wrote  Jul 1 2009 at 9:56 PM  
Will we ever get support for the Ribbon?

cjmarsh wrote  Jul 8 2009 at 10:35 AM  
Hi there - will there be support for the Mobile Broadband API at some point?

REVAN wrote  Jul 10 2009 at 8:19 PM  
Thanks for nice Lib. I'm interesting about support of D3DX general and D3DX Math. And, like a RyGuy12, what about Ribbon?

sumitmsft wrote  Jul 10 2009 at 9:49 PM  
RyGuy12 - The V1.0 release of the Code Pack will not have support for Ribbon. We are considering this feature for future versions.

cjmarsh - Thanks for the feature request. We will add Mobile Broadband API support to the list of potential candidates for future releases.

REVAN - We do not have full support for D3DX but we have basic Math and utilities library that we have used to build our samples. In addition, the included DirectX utilities (in Samples) show how to wrap D3DX interfaces and methods.

Christianhood wrote  Jul 14 2009 at 5:08 PM  
Same question as wayne_p:
"Will these become a part of .NET Framework 4.0? If not, at what point will they be added?"

xyzzer wrote  Jul 15 2009 at 4:48 PM  
I wouldn't say it could be included there - the Beta version does not include it, so why the released version would? Anyway - why would you like it included there? Isn't it better to just have the source code that you can bend to your needs easily?

MikeH wrote  Jul 25 2009 at 8:03 AM  
@cjmarsh - There is already a whitepaper on using Mobile Broadband API with managed code at http://www.microsoft.com/whdc/connect/wireless/MB_ManagedCode.mspx

Shemmie wrote  Aug 9 2009 at 5:40 PM  
May I just add - that this could be the greatest single thing Micrsoft could have done to drive Vista / Windows 7 adoption. Core API's moved to managed code - it's like my birthday come early. Thank you.

DimitarCC wrote  Aug 11 2009 at 5:44 AM  
Thanks for that API! I will start using it right now to code applications compatible with Windows 7.

Timbot wrote  Aug 11 2009 at 1:40 PM  
i'm just curious (and i've seen a few others) if there's something like this for windows xp that anyone knows about? we're kind of stuck on it here at work...

ThomasLebrun wrote  Aug 19 2009 at 10:11 AM  
For those who want to use biometric features from Windows 7, you could take a look here: http://weblogs.asp.net/thomaslebrun/archive/2009/08/19/windows-seven-how-to-use-biometric-authentication-in-your-net-applications.aspx

REVAN wrote  Aug 19 2009 at 3:15 PM  
Is there are any plans for Media Foundation wraper in next releases?

rctaubert wrote  Aug 25 2009 at 11:33 PM  
I have taken the sample for the Shell PropertyEdit Sample, rewrote it for a form app and it works great on Vista. Is there a way to get it to work on an XP computer????

I have installed Framework 3.5 sp1 on the XP machine and the program will run without exceptions.

The program contains four function:
1. Get property value
2. Set property value
3. Enumerate properties and values.
4. Give information about a specific property name.

On the XP computer the program will run without errors but only function #4 will return a value.

I hope their is just something I am missing.

sevenalive wrote  Aug 26 2009 at 7:57 AM  
Please drop the WinForms Dependencies. if you want everyone to use WPF then stop using WinForms. For the next release you should split more code into the "Core" library and then have WPF library and a WinForms library.

BillGatesII wrote  Aug 26 2009 at 3:52 PM  
THANK YOU! this is so much easier then having to look around the web for something.
I'm just woundering, is there any thing for the new VHD API in this?

CElliott wrote  Aug 29 2009 at 11:56 PM  
The newer Intel CPUs have a built-in floating point operations counter. Will Windows 7 provide an interface to this counter? In other words, will it be possible to call something like QueryPerformanceCounter() to access the FLOPs that a program has executed?

Keeron wrote  Aug 30 2009 at 1:06 AM  
@CElliott: Looks like the APIs are already there and easily callable from .NET (using pinvoke):

MSDN: http://msdn.microsoft.com/en-us/library/dd458671(VS.85).aspx
PInvoke: (only couple; I am sure you'll find others on pinvoke.net)
http://www.pinvoke.net/default.aspx/kernel32/QueryPerformanceCounter.html

and

http://www.pinvoke.net/default.aspx/kernel32/QueryPerformanceFrequency.html

DeniseMToronto wrote  Oct 5 2009 at 12:48 AM  
I can only assume most of the installation instructions have been left out. They didn't even say to use C#. C# couldn't find the files in the locations the ZIP folder put them. The supposedly VB samples are looking for C files! Microsoft, how about some instructions on how to actually install and use these!

Keeron wrote  Oct 9 2009 at 2:20 AM  
There is nothing to "install" ... It's a zip file with sources and samples. Download the file, unzip, run the samples SLN files.

xyzzer wrote  Oct 9 2009 at 5:42 AM  
Well, of course you need a few things, like .NET 3.5, Visual Studio seems pretty useful, so is a C# or VB compiler and C++ for DirectX, Windows SDK and DirectX SDK. I suppose C++ was missed from the list, but really everything else is mentioned above.

arikp wrote  Oct 12 2009 at 8:09 AM  
Check Windows Ribbon for WinForms at [url: http://windowsribbon.codeplex.com/]
This is my work for provding .NET WinForms users access to the ribbon feature.
It is build on top of Windows API Code Pack and tries to follow the same convensions.
Sample projects included.

HappyBunny wrote  Oct 15 2009 at 8:17 AM  
Is there any plan to include the WINSCARD functions in a later release?

jcdickinson wrote  Nov 4 2009 at 8:56 AM  
DirectCompute would be a nifty one. It would be great to be able to speed up math-heavy .Net apps without having to resort to unmanaged code.

robertgraziano wrote  Nov 5 2009 at 3:08 PM  
Shouldn't this be rolled into a .NET Framework release/update? It'll make it easier to roll out the runtimes to servers/workstations. Nice features, by the way. As someone else pointed out, DirectCompute would be nice...

xyzzer wrote  Nov 21 2009 at 8:40 PM  
Awesome! Can't wait to play with it!

thwart wrote  Nov 25 2009 at 12:01 AM  
So does this mean the Microsoft supports access to DirectX with Managed code? How is this different from Managed DirectX? What does this mean for XNA? Can I assume that XNA is what Microsoft is still pushing for Indy game development?

thwart wrote  Nov 25 2009 at 12:02 AM  
This is great news for tool development. By that I mean access to DirectX through Managed code.

Zyphrax wrote  Dec 9 2009 at 1:09 PM  
Why did you choose a minimum of .NET 3.5 SP1? If you could lower that to 3.0 or even 2.0 a lot more people would start using it. Great set of tools though, I think they should be part of the framework, nice WPF controls.

felizk wrote  Dec 13 2009 at 11:42 PM  
Is there any plan to add an API for controlling the Desktop Wallpaper Slideshow?

arikp wrote  Dec 22 2009 at 11:06 PM  
I'm proud to present [url:Windows Ribbon for WinForms|http://windowsribbon.codeplex.com/],
a library for using windows ribbon in WinForms applications.
It is a managed wrapper around the Windows Ribbon Framework (formerly known as Scenic Ribbon)
and includes all the ribbon features supported by the framework.
The [url:documentation|http://blogs.microsoft.co.il/blogs/arik/archive/2009/12/23/windows-ribbon-for-winforms-part-0-table-of-contents.aspx]
shows how to use every feature from a WinForms application.
Also, the project site contains 18 sample applications that showcase every feature along with the full source code of the wrapper library.

Bokonon wrote  Jan 5 at 10:26 PM  
As others have suggested, this is a great set of tools, but many of us out here in the "real world" are still working with .NET 2.0, so your decision to require .NET 3.5 SP1 is very, very disappointing. Why should I have to force all of my users to upgrade to .NET 3.5 SP1 just so that those of them who run Windows 7 can have a measly jump list with custom tasks? Is that too much to ask?

sevenalive wrote  Jan 11 at 10:41 PM  
@bokonon, You could strip out what you need or even remove the incompatible code and reduce the .net framework. Most people have at least 3.0 if not 3.5 sp1. Once you get the framework installed, windows update auto updates that version. Vista has 3.0 built in, Windows 7 has 3.5 sp1 built in. So the only real problem would be XP users, and imo that isn't going to be a issue in about 1-2 years. Try to see if it runs the 3.5 client profile.

BTW, the 4.0 client profile, is a huge improvement and 4.0 is coming around the corner. My apps require 3.5 for the linq and other efficiencies and it hasn't been a problem for my userbase.

Piklets wrote  Jan 19 at 11:02 AM  
How are we supposed to use this with Visual Basic? Instead of C# that is...

REVAN wrote  Jan 25 at 12:29 PM  
Have any plan to multi targeting for frameworks? Net 4.0 can't using dll without recompile and 2.0 version will be nice for mainstream. And why no support of media foundation in interop maner for example?

general wrote  Jan 31 at 3:42 PM  
If you are using .Net 2.0 you can on startup check if current user uses Windows 7, and then invoke CodePack's methods via Reflection. You have to add compiled dlls like Microsoft.WindowsAPICodePack.dll into your .Net 2.0 output directory. If user uses Win7, load this assembly using Assembly.Load("Microsoft.WindowsAPICodePack") and then invoke all needed methods.

Using Reflection provides no need to reference CodePack's .Net 3.5 dlls into your .Net 2.0 project. This is dirty method, but effective and simpler than using native calls to Windows API.

IMPORTATNT: You can also create a .Net 3.5 project that uses CodePack and initializes all needed things (like JumpLists). This project could contain only one class (eg. Win7Initializer) with one method (eg. void Win7Initializer.Initialize()). This method has to initialize Win7 features. Compile it into eg. Win7Initializer.dll. Then in your .Net 2.0 project check if user uses Win7 and then use reflection to load Win7Initializer.dll and call only ONE method: Win7Initializer.Initialize. Simple?

Updating...
Page view tracker