tags:

views:

120

answers:

5

I recently needed to find the .NET equivalent to ShellExecute, and I was happily able to find the answer quickly at StackOverflow. But surely there must be document or a list somewhere which would have given me this answer just a little quicker.

Back when I went from ANSI programming to UNICODE, Microsoft had this handy page of routine mappings:

http://msdn.microsoft.com/en-us/library/Aa272889

I put some of it into a text file, and when I needed to know, say, the Unicode equivalent of strlen, I'd just grep the file for strlen and I'd get:

C:\> grep strlen textfuncs.txt

strlen    _tcsclen
strlen    _tsclen

Does anyone have, or know of, a list like that for Win32 -> .NET?

+1  A: 

Not exactly a 1-1 mapping but you can find most things related to using Win32 calls in .NET at: http://www.pinvoke.net.

Lots of Win32 functions, related documents and sample codes are there.

chakrit
+1  A: 

This site is excellent for .NET to Win32 interop:

PInvoke.net: the interop wiki

There are "Alternative Managed API" entries where available, but due to the fine grained nature of the Win32 API's there may not be an equivalent in the managed API. A single method in the managed API may require several calls to Win32 across multiple libraries to achieve a single task.

Asking for exact equivalents would be like asking what's the managed equivalent of an assembly language instruction when the managed language/API doesn't provide that level of granularity.

Kev
This does not in general do what he wants.
SLaks
No. He wants classes or methods in the BCL that are equivalent to Win32 APIs. He isn't asking for `[DllImport]` s.
SLaks
@Slaks - if you look carefully at the site there are "Alternative Managed API" descriptions where available.
Kev
@Slaks: Clearly you have never used pinvoke.net. It is EXACTLY what was requested. For example, on http://www.pinvoke.net/default.aspx/shell32/ShellExecuteEx.html you will find a section "Alternative Managed API" with an example of Process.Start
Ben Voigt
However chakrit got his very similar answer in just a couple seconds earlier.
Ben Voigt
@Ben: I'm aware of that. However, it is very incomplete.
SLaks
@Slaks - it's incomplete because as many have pointed out there aren't always direct equivalents due to the low level nature of Win32. It's the closest resource the OP is going to find that meets his needs.
Kev
@SLaks, @Kev: I rather suspect it's incomplete because it's waiting for community contributions. It's not expected that one Win32 API function will be replaced by one .NET method, even for the example shows, replacing `ShellExecuteEx` requires using most of the properties and methods of the BCL `Process` class. But that's not really a problem since the "Alternative Managed API" is free-form text, not merely a link to a single MSDN page.
Ben Voigt
+3  A: 

As the .net API is a full fledged object library. It would be hard to have a one to one mapping from win32 to .net. But in most cases a quick google search will be able to get you to the correct class.

rerun
+6  A: 

Part of the problem here is that Win32 doesn't migrate directly to .NET.

The .NET Framework handles most of the Win32 API functionality, but it does so in a very different manner. Instead of trying to just map functions, it maps functionality into framework types. Sometimes, this is a very straight mapping, but sometimes, many different APIs are mixed together, and parts are rewritten in managed code, etc.

Typically, a quick search for your "goal" instead of the function will turn up the proper API very quickly.

Reed Copsey
+1  A: 

Aren't you looking for something like this:

Microsoft Win32 to Microsoft .NET Framework API Map

steinar
PInvoke.net is pretty helpful too, but the MS page linked to above is closer to what I was looking for (for instance it's all on one page). If only it was more complete. Thank-you to everyone for your help.
Jeff Roe