Search Wiki:

The Windows® API Code Pack for Microsoft® .NET Framework provides a source code library that can be used to access some new Windows 7 features (and some existing features of older versions of Windows operating system) 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) of the library are:
  • Windows 7 Taskbar Jump Lists, Icon Overlay, Progress Bar, Tabbed Thumbnails, and Thumbnail Toolbars.
  • Windows 7 Libraries, Known Folders, non-file system containers.
  • Windows Shell Search API support, a hierarchy of Shell Namespace entities, and Drag and Drop functionality for Shell Objects.
  • Explorer Browser Control.
  • Shell property system.
  • Windows Vista and Windows 7 Common File Dialogs, including custom controls.
  • Windows Vista and Windows 7 Task Dialogs.
  • Direct3D 11.0, Direct3D 10.1/10.0, DXGI 1.0/1.1, Direct2D 1.0, DirectWrite, Windows Imaging Component (WIC) APIs. (DirectWrite and WIC have partial support)
  • 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):
The new features added in this update of code pack are:
  • Shell Search API support.
  • Drag and Drop functionality for Shell objects.
  • Support for Direct3D and Direct2D interoperability.
  • Support for Typography and Font enumeration DirectWrite APIs.

Other enhancements done in this update are:
  • Bug fixes in all areas.
  • Performance optimizations.
  • Some improved and new samples (esp. for the new features in this release).
  • Improved API reference documentation.

Requirements:
  • Minimum .NET Framework version required to use this library is 3.5 SP1.
  • This library targets the Windows 7 RTM version (now available to MSDN subscribers), though many of the features will work on the older versions of Windows operating system.
  • DirectX features require Windows SDK for Windows 7 RTM. Additionally, some Direct3D samples require the March 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 downloaded section.

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 remove that error, please unblock the help files and zip file before extracting it (right click the file | select properties | click Unblock button).

Videos:
Two minute videos demonstrating some of the features in this release are now available:


Last edited Aug 8 2009 at 12:23 AM  by sumitmsft, version 40
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 2010 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 2010 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 2010 at 11:02 AM  
How are we supposed to use this with Visual Basic? Instead of C# that is...

REVAN wrote  Jan 25 2010 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 2010 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?

REVAN wrote  Feb 24 2010 at 11:50 AM  
Just found pure managed GXDI library [url:http://mdxgi.codeplex.com/] it doesn have problems with X64.

xyzzer wrote  Mar 31 2010 at 6:25 AM  
Congrats on another 60k downloads! :)
Just wondering... would this run on a Surface? I am tempted to try...

sevenalive wrote  Jun 9 2010 at 1:18 AM  
If your developing on .Net 4, then you really don't need this codepack if you just want Win7 feaures. However I need it for a vista/7 dialog in .Net still.

Schbodz wrote  Aug 7 2010 at 9:34 PM  
Is rerealsing code taken from the api pack under the Ms-PL covered by the custom license attached to this a legal action?

lazlolussierbonin wrote  Oct 13 2010 at 10:07 PM  
Can't extract the pack. I see the progress bar for half a second then nothing.

AbstractViews wrote  Oct 19 2010 at 11:07 AM  
I would like to receive an e-mail contact for looking at further samples on the Windows API CodePack, which contains simple examples of PIDL's, or ITEMIDLISTS, which are quite well-documented on the samples and documentation with simple examples of what you need to do to create an IntPtr to a file, but do not show code for writing a pidl from a higher level as a file although the conversion of an IShellItem to an IntPtr pidl is quite obvious.
The codepack is a good start, but where to do I need to look to find more about IShellItem and IShellItem2 as well as ShellObject, ShellContainer and ShellFolder. The current searches I have done on Bing and MSDN do not give the one line of code that explains a pidl or a line of code that explains say a cut and paste or a drag and drop in detail. I am currently trying to write this functionality in an application as a combination of the ExplorerControl on WindowsAPICodePack and a combination of a TreeView and a ListView.
I have tried the easy samples on the CodePack such as the ExplorerBrowser, which enable writing an ExplorerBrowser control in a window, but cannot see how to access the ListView or the TreeView in code from the ExplorerBrowserControl property since there is no Property, method or member variable that can gain access to the treeview or listview apart from Navigate in the ExplorerBrowserControl. Is there a property or method or interface that can directly access the TreeView , ListView in the control.

tronda wrote  Oct 22 2010 at 8:23 AM  
Wonder if some in the team could shed some light on this issue: http://stackoverflow.com/questions/3978587/using-windows-7-taskbar-progress-indicator-from-a-windows-explorer-namespace-exte

squan888 wrote  Nov 30 2010 at 3:57 AM  
To migrate the Controls project to Visual Studio 2010 the Target Name needs to be changed from $(ProjectName) to Microsoft.WindowsAPICodePack.DirectX.$(ProjectName).

squan888 wrote  Nov 30 2010 at 3:58 AM  
To migrate DirectX.vcproj to Visual Studio 2010 the project file has be changed from being saved as UTF-8 to being saved as ANSI. Use Notepad to do this.

yzorg wrote  Feb 20 2011 at 5:45 AM  
Someone created a nuget package for this code pack but used 1.0 instead of the latest 1.1. 1.0 is missing many APIs including WPF Explorer Browser (IIUC). The owner of Windows Code Pack should contact the nuget maintainers (David Ebbo @ ms, Phil Haack) to get the package updated.

guercheLE wrote  Mar 3 2011 at 7:36 PM  
I am intending to create a small system tray application to let me shuffle themes (not background images only) from time to time (every 5 hours) and I am wondering if it is possible to achieve what I want just using "Windows® API Code Pack for Microsoft® .NET Framework" and managed code.

beth62 wrote  Apr 22 2011 at 5:12 PM  
The link above for the Explorer Browser video is dead:

http://www.microsoft.com/visualstudio/buildabetterapp/watch/explorer-demo.aspx

Kevininstructor wrote  Jun 5 2011 at 2:06 AM  
Using VS2008 on Vista I tried the VB.NET project AppRestartRecovery. Ran the project, opened a simple text file, waited over 60 seconds then crashed the app. I watched all debug messages using DBWin32 and all appeared to work as excepted but the app did not restart. Any ideas why it would fail to restart?

JacobPitts wrote  Aug 19 2011 at 9:26 PM  
Two broken links on this page:
Explorer Browser
Common File Dialog

BiggestWave wrote  Sep 8 2011 at 12:34 PM  
The above mentioned links to Explorer are *still* broken!

sevenalive wrote  Sep 13 2011 at 4:38 AM  
In TaskDialog.cs this is an artifical limitation. I commented out the exception and never had a problem having a custom default button and a standard cancel button. Might want to review some of these check's because this wasn't the only one I found like this.

//if (buttons.Count > 0 && standardButtons != TaskDialogStandardButtons.None)
//{
// throw new NotSupportedException(Properties.Resources.TaskDialogSupportedButtonsAndButtons);
//}

You can have custom and standard buttons in the same taskdialog, even the MSDN examples say you can, not sure why whoever did this thought different.

alun wrote  Oct 31 2011 at 12:36 AM  
A couple of things I would like to see in the PropertySystem code:
1. System.RecordedTV.OriginalBroadcastDate seems to fail every time I set it on an MP4 file, and does not read correctly out of MP4 files that have been edited by the Zune software to have a broadcast date. [I have sample code if you want to play with this]
2. I would really like to see IStream support to allow me to set ThumbnailStream on MP3 and MP4 files. Is that at all possible for the future?

LordHog wrote  Nov 8 2011 at 11:06 PM  
Has this project been abandoned?

mike6518 wrote  Nov 30 2011 at 7:33 PM  
Will there be any new release? Thanks.

ronaldhorn wrote  Apr 13 2012 at 3:48 PM  
Is this still being supported? Will the binaries work on Windows 2003 server?

mdavidjohnson wrote  Jun 2 2012 at 8:42 PM  
The blog links on this page appear to be broken.

Updating...
Page view tracker