Reputation: 19041
Suppose I have a file which imports a number of functions from dll, before every function I must put:
[DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)]
But it is boring and code becomes longer -> harder to understand, in C I can use define like this:
#define DLL_IMPORT [DllImport(...)]
What can I do in C#?
Upvotes: 3
Views: 79
Reputation: 4363
You can use P/Invoke Interop Assistant to make your job a little easier. This tool automatically generates managed p/invoke declarations (in C# or VB) from native signatures. http://blogs.msdn.com/b/bclteam/archive/2008/06/23/p-invoke-interop-assistant-justin-van-patten.aspx
Upvotes: 1