Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
Comments (misc)
A place to leave general comments about the site.

Leave your comments here! -- Adam Nathan

In addition to "giving a man a fish", shouldn't we also be "teaching a man how to fish"?

Why not have a section that explains how to read the API definitions and translate them into C# and VB.Net equivalents. I could probably get something started, if you guys find a place for it.


It's great to see a wiki for P/Invoke, do you have any plan to setup a wiki for COM interop?


Ying-Shen Yu

I was quite excited when I found this site, but I was somewhat disappointed with the incomplete nature of some of the information. For example, I was looking for some assistance with the SHBrowseForFolder call from Shell32, and I did find it -- but it is only a tease since the definition for BROWSEINFO is not available! OK, so I had figured most of that part out myself, but I then looked for details on SHGetDesktopFolder, and the same thing is true -- there is no definition of the output of that call!

[Note from Adam: I just added 2 pages, so SHBrowseForFolder links to the BROWSEINFO structure, which links to the BrowseCallbackProc delegate used as one of its fields. The more that people can add stuff when they don't find it, we'll hopefully have fewer people feeling teased!]

I need to use this call to permit the user to browse the network neighborhood and select a specific computer system, and the .Net implementation of the wrapper for this does not seem to support the BIG_BROWSEFORCOMPUTER option! If anyone has figured this out, could they please post the information to this web site and let me know at Thanks.

Upon seeing this I realized that a Microsoft.Win32.dll is possible. Has anyone tried 'mechanically' creating such a library? I'm sure others are thinking about it. Cut and paste is nice, but no work is better Maybe there would be Micrsoft.XP.Win32.dll, Microsoft.2000.Win32.dll as well? I'm ready to go to work, any takers?


Very cool site. Somebody needs to write game theory analysis of the developer community.

This is such a great idea -- thanks Adam

..BradA (

Echo Brad. This is an awesome idea! Thanks Adam. I have blogged it. -- Sam Gentile (

Great idea, thanks for creating the site. However, it does have rendering problems on Mozilla (Firefox 0.8 on Win XP to be exact). The directory tree (advapi32, gdi32 etc.) is misplaced (overlaps the "Directory" label) and I can't get them to expand.

There is also IE (6.0.2800.1106.xpsp2) bug: clicking "Edit This Page" brings up error message "A runtime error has occurred... Line: 15 Error: 'ButtonBar' is undefined". Harmless but annoying.

Krzysztof Kowalczyk (

The fading effect is awesome, the whole experience is extremely 'organic'. This is really the future of documentation.

This is so cool! And work with Wiki has never been more enjoyable.

Great idea, thanks for setting it up!

One question: The APIs here appear to be mechanically created from some other source - from things like "System.Windows.Forms.NativeMethods"? The functions are present, but not the structures and data types used in the params. Any plans to do a mechanical dump of the structures as well? The real magic of marshalling is getting the param types set up correctly, which for structures can be quite a pain.

Things like RegisterWindowClass and GetClassInfo using the WNDCLASS structure in different ways requires creating separate structures with different field types in order to satisfy the marshaller (The WndProc pointer as a raw IntPtr in some cases, or as a method pointer in other cases). I can see that the params for GetClassInfo and RegisterWindowClass do take different structure types, but those types do not appear to be documented here.



You should also check out these automatically generated PInvoke stubs which covers much of the WIn32 API



Peter Hallam

C# Compiler Dev Lead

How about a directory for the Compact Framework/coredll? - Ian Darling

This is great, but definitely needs somewhere we can define common constants and structures.


- Add a way to search and or highlight entries that have additional info added.

- Add a logon feature (use DotNetNuke?) to allow added posts to be tracked based on email address instead of IP address.

Charlie Kindel (

Some responses for the last 3 comments:

  • Ian, I've added coredll, so feel free to start adding pages!
  • Rodney, you can define pages for structures, etc. just like you can for functions. It might be nice to organize them differently, though...
  • Charlie, I'll have to consider other means of tracking. In the meantime, it would be great if folks fill out the "Identity" text box when making edits. Also, you can click on the "Show Recent Changes" link to see the most-recently-updated pages across the site.

Thanks, everyone, for your participation! -- Adam Nathan

  • Adam:We are working on a login provider for tracking postings for our own FLexWiki. Please contact me about it -- Mike Schinkel <mikes(at)xtras(dot)net> [2004-07-08]

Very nice But I also miss the structures, constants, etc. Would it be possible to organize the information such as the MSDN Library does instead? I believe it will be hard to find items in for example the shell32 tree when all enums, structures, interfaces etc. are added.

I'm thinking something like this instead:


  +-----Callback functions
  +-----Constants, Enumerations, and Flags
  +-----(Maybe more?)

Or is it possible to do this now giving a pagename such as shell32.Structures.APPBARDATA?

-- Andreas Häber


Guess I'll get started soon

Ian Darling.

Dang - I think I broke kernel32.CreateFile when adding coredll.CreateFile - Ian Darling

[Note from Adam: This is now fixed, and was actually unrelated to coredll.CreateFile. Thanks!]

Thank you very much, I've been waiting for something like this for a long time now.

Mark Fernandes.

Great idea. I would also be interested in a category on PInvoke how-tos. for example I'm still trying to figure out how to unmarshal an array of delegates on the unmanaged side - feel free to chime in if you happen to know that


Great job, this helps me alot.

Could you add for avifil32.dll?

[This is done. -Adam]


Adam - cheers. Can we add aygshell.dll too (another Pocket PC one)?

[This is done. -Adam]

Maybe Pocket PC stuff should be split off into a separate namespace?

[That's a good idea. For now, I'll leave them in the same list but as it grows I'll probably separate them somehow. -Adam]

Ian Darling

It would be GREAT if we had a project on here to do all of the interfaces. (i.e. IOleObject etc.) We could work on doing the entire MSHTML.dll with all of the interfaces etc. This is what kills me constantly.

Love the site! Great help!

James Hancock

Adam, this is an excellent and innovative site. I will bookmark it and share it with our programmers. Thanks a lot!

Tommie Carter

Adam great work. Can we add msi.dll?

David M. Kean

[Thanks, I've added it. -Adam]

Code Syntax Highlighting Suggestion


Greate Job! I installed Flexwiki out of the box and it is not the same. This site is much better (you fixed and improved a lot of things in Flexwiki). Now I am learning more about PInvoke

If I may suggest, how about code syntax highlighting similar or better to what is done in ? That is, for example, in the preformatted part, <PRE> If it starts with '//' highlight Csharp words until the end </PRE>. Great for sample codes in this site. Or since this wiki is all about codes in C#, why not do syntax coloring in all preformatted texts? Just a thought.

Elrey Ronald (

So, Casey Chesnut and I ( are working on some high-powered Compact Framework stuff and we realized that many of the P/Invoke calls here may not work for the Compact Framework. It may be useful to add a Flag or Field indicating whether it is or not supported by the Compact Framework. We could actually follow the pattern that the OpenCF people use in listing both the desktop and the CE P/Invokes on the same page and have it link to the right one. We can start making some contributions as well.

Sam Gentile (

like from our email:

The marshalling restrictions are one problem, as well as which DLL is actually used. From the CF side, we usually do the dumb downed one to work on both desktop and device.

Then you only have to change which DLL the call goes to;

e.g. pointing to User32.dll for desktop or coredll on the device.

The OpenNetCF guys have a better pattern.

They implement it to work on both following the pattern below, to have the method work on both desktop and device.


public static bool CPAcquireContext(out IntPtr phProv, StringBuilder pszContainer, uint dwFlags, byte[] pVTable){

  if(Environment.OSVersion.Platform == PlatformID.WinCE)
    return CPAcquireContextCe(out phProv, pszContainer, dwFlags, pVTable);
    return CPAcquireContextXp(out phProv, pszContainer, dwFlags, pVTable);


[DllImport(“coredll.dll”, EntryPoint="CPAcquireContext", SetLastError=true)]

private static extern bool CPAcquireContextCe(out IntPtr phProv, StringBuilder pszContainer, uint dwFlags, byte[] pVTable);

[DllImport(“advapi32.dll”, EntryPoint="CPAcquireContext", SetLastError=true)]

private static extern bool CPAcquireContextXp(out IntPtr phProv, StringBuilder pszContainer, uint dwFlags, byte[] pVTable);

-- Sam Gentile

[The site already contains coredll.dll with its own pages, so hopefully that helps. Any advice you folks have on how to make the site more useful for Compact Framework users is definitely appreciated! -Adam]

This site's been live for about a month, now -- either it's not getting indexed completely by Google, or there is nearly complete neglect for SetLastError=true. Or both.

IMHO, the hardest part of developing a good p/invoke signature is not substituting "LPCSTR" with "string" -- it's looking up the failure semantics of the methods' return values... (NULL or INVALID_HANDLE? Does it SetLastError? etc.) And then wrapping the call appropriately.

Can we come up with some sort of standard, for that?

I'd go so far as to recommend always mandating SetLastError -- explicitly setting SetLastError=false, to call out the (comparatively rare) Win32 functions that don't expose a failure path through GetLastError.

And SetLastError is only half the problem -- remembering to actually check the return value is the other half! We should compel folks to check the return values properly, in the sample usage section -- assert success and/or throw Win32Exception, as appropriate.



I notice that the winscard.dll p/invoke functions are not complete! Missing SCardReconnect and SCardGetAttrib. There is more thing is that some of the parameters have In in there. What does that mean? Thanks.


the In are attributes. Oops, never used it before until recently. I will soon write on PCSC calling winscard. Will update here, if i able to get it work. Thanks.

Chua Wen Ching,

This site is just great! I've already added it to the company's official list of valued web sites for developers!

We'll try to add new stuff as well as just use stuff!

Matthew Watson

I love this site!

Should we standardize on using "int", "bool", "string", etc. in C#, or on "Int32", "Boolean", "String"?

Whoever has the power of deletion needs to remove shlwapi.StringBuilder.

And I think the templates, which seem to vary from one DLL to the next, generally should start by filling out the "SetLastError=true, CharSet=CharSet.Auto", which is applicable more often than not and too easily neglected.

Luke Stevens,

Access directly from VS:
Terms of Use
Find References
Show Printable Version