Search code examples
c#interopdllimport

Is there a more painless way to call Win32 from C#?


Every few months I find myself needing to call Win32 from C#. Though I've done it a dozen times, I've usually forgotten the exact machinations, so I poke around the web or old code and figure out what DllImport statements I need, etc.

Am I alone?

Is there a sanctioned "Win32" class that has the requisite declarations for the entire Win32 API? Seems like there ought to be. Maybe I'm missing something.


Solution

  • You may find http://www.pinvoke.net helpful.

    Also, for common Win32 functions, you could try the P/Invoke Interop Assistant.