Hi Guys
Besides for reasons which drive us into making API calls, why else would one need to use DllImport ? How different is this from adding a reference to a Library - creating instance of it and then using it ?? Please let me know.
Thanks
Suhaib
Printable View
Hi Guys
Besides for reasons which drive us into making API calls, why else would one need to use DllImport ? How different is this from adding a reference to a Library - creating instance of it and then using it ?? Please let me know.
Thanks
Suhaib
Hi Suhaib,
There are no other reasons! DllImport is required to identify methods in external "unmanaged" DLLs.Quote:
Besides for reasons which drive us into making API calls, why else would one need to use DllImport ?
This only works for .NET DLLs.Quote:
How different is this from adding a reference to a Library - creating instance of it and then using it?
You forgot that you can use C++.NET to access unmanaged dlls or COM objects.
Actually, I made the point that it shouldn't exist - it promotes bad practice when people try to take shortcuts by just calling the Win32 functions that they know.
However, it would cripple the language in this respect.
Darwen.
I know what you mean. Fortunately I do not have a Win32 API or even C++ background, so I only use them as a last resort.
Occasionally though it seems that useful functionality is "missing" from a given component or assembly. A recent example is being able to drag and drop Images cf. ImageList_Drag* API.
Anyone know if Microsoft will be filling the gaps in later releases?
Anyone tha thas a good tutorial on how to use DllImport?
need to use a C++ dll given by I/O card supplier to be used in C#