CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2003
    Location
    Bangalore, INDIA
    Posts
    180

    Why do we need DllImport ?

    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

  2. #2
    Join Date
    Dec 2003
    Location
    http://map.search.ch/zuerich.en.html
    Posts
    1,074

    Re: Why do we need DllImport ?

    Hi Suhaib,
    Besides for reasons which drive us into making API calls, why else would one need to use DllImport ?
    There are no other reasons! DllImport is required to identify methods in external "unmanaged" DLLs.

    How different is this from adding a reference to a Library - creating instance of it and then using it?
    This only works for .NET DLLs.

  3. #3
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Why do we need DllImport ?

    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.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  4. #4
    Join Date
    Dec 2003
    Location
    http://map.search.ch/zuerich.en.html
    Posts
    1,074

    Re: Why do we need DllImport ?

    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?

  5. #5
    Join Date
    Dec 2000
    Location
    Singapore
    Posts
    149

    Re: Why do we need DllImport ?

    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#

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured