Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Question about DllImport

Question about DllImport

Scheduled Pinned Locked Moved C#
questioncomcsharpc++tools
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zultan
    wrote on last edited by
    #1

    Hello, I'm posting what I hope will not be too ignorant of a question regarding com interop :-) A number of times I've seen in examples on this site a piece of code where the author has used com interop to call a method from an external dll (I assume c++ dlls being called from the c# code). My question is if you did not author the c++ dll yourself what is the best method to find out what the classes, methods, etc are that are contained in the dll? Basically, where do you determine what it is that you need to call from the dll? For example, consider this call to an external dll (from an article here on Code Project): private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); How did the author determine that in the dll that he called that there is a WritePrivateProfileString method and that it takes 4 string parameters? Is there some utility out there that allows you to browse c++ dlls and that you can use to determine what method and parameters you would need to import? Bear in mind that I'm still learning c# and com interop is one subject that I've struggled to understand fully. Thanks.

    C 1 Reply Last reply
    0
    • Z Zultan

      Hello, I'm posting what I hope will not be too ignorant of a question regarding com interop :-) A number of times I've seen in examples on this site a piece of code where the author has used com interop to call a method from an external dll (I assume c++ dlls being called from the c# code). My question is if you did not author the c++ dll yourself what is the best method to find out what the classes, methods, etc are that are contained in the dll? Basically, where do you determine what it is that you need to call from the dll? For example, consider this call to an external dll (from an article here on Code Project): private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); How did the author determine that in the dll that he called that there is a WritePrivateProfileString method and that it takes 4 string parameters? Is there some utility out there that allows you to browse c++ dlls and that you can use to determine what method and parameters you would need to import? Bear in mind that I'm still learning c# and com interop is one subject that I've struggled to understand fully. Thanks.

      C Offline
      C Offline
      Corinna John
      wrote on last edited by
      #2

      The DLL has to be documented. That means, the signatures of the functions are described in a text file. MSDN contains a bit of documentation for all Win32 DLLs. If a DLL has no documentation, you're not supposed to use it. ;) Look, there are the MSDN pages for WritePrivateProfileString and the whole platform SDK. _________________________________ Please inform me about my English mistakes, as I'm still trying to learn your language! -- modified at 17:10 Friday 14th April, 2006

      Z 1 Reply Last reply
      0
      • C Corinna John

        The DLL has to be documented. That means, the signatures of the functions are described in a text file. MSDN contains a bit of documentation for all Win32 DLLs. If a DLL has no documentation, you're not supposed to use it. ;) Look, there are the MSDN pages for WritePrivateProfileString and the whole platform SDK. _________________________________ Please inform me about my English mistakes, as I'm still trying to learn your language! -- modified at 17:10 Friday 14th April, 2006

        Z Offline
        Z Offline
        Zultan
        wrote on last edited by
        #3

        Thanks :-)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups