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. Calling code from Win32 dll

Calling code from Win32 dll

Scheduled Pinned Locked Moved C#
8 Posts 4 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.
  • _ Offline
    _ Offline
    _AnsHUMAN_
    wrote on last edited by
    #1

    Hello Masters, Can you just put some light on which is the best way to invoke function's from a Win32 dll? I have already studied the following ways: Solution A: Create Bridge Functions and Use PInvoke. Solution B: Create a Bridge DLL in Managed C++. If we don’t have the source code for the dll’s this approach would be better. Also do we need to write a wrapper for each and every function a WIN32 dll exposes?

    You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

    G L N 3 Replies Last reply
    0
    • _ _AnsHUMAN_

      Hello Masters, Can you just put some light on which is the best way to invoke function's from a Win32 dll? I have already studied the following ways: Solution A: Create Bridge Functions and Use PInvoke. Solution B: Create a Bridge DLL in Managed C++. If we don’t have the source code for the dll’s this approach would be better. Also do we need to write a wrapper for each and every function a WIN32 dll exposes?

      You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      If you are calling small amount of functions or performance is not very critical you can use P/Invoke approach. If performance is an issue, use managed c++

      Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion

      _ 1 Reply Last reply
      0
      • _ _AnsHUMAN_

        Hello Masters, Can you just put some light on which is the best way to invoke function's from a Win32 dll? I have already studied the following ways: Solution A: Create Bridge Functions and Use PInvoke. Solution B: Create a Bridge DLL in Managed C++. If we don’t have the source code for the dll’s this approach would be better. Also do we need to write a wrapper for each and every function a WIN32 dll exposes?

        You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, I use P/Invoke to call native code. When I am in charge of the native code's API, I keep it as simple as possible, so not to rely on automatic marshaling which tends to cause data copying if one isn't careful. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


        _ 1 Reply Last reply
        0
        • G Giorgi Dalakishvili

          If you are calling small amount of functions or performance is not very critical you can use P/Invoke approach. If performance is an issue, use managed c++

          Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion

          _ Offline
          _ Offline
          _AnsHUMAN_
          wrote on last edited by
          #4

          so you suggest to write a wrapper for the exposed functions from the dll in managed C++ before using them? I knowthat the number of functions in the C++ dll are more than what you would call manageable.

          You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

          1 Reply Last reply
          0
          • L Luc Pattyn

            Hi, I use P/Invoke to call native code. When I am in charge of the native code's API, I keep it as simple as possible, so not to rely on automatic marshaling which tends to cause data copying if one isn't careful. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


            _ Offline
            _ Offline
            _AnsHUMAN_
            wrote on last edited by
            #5

            I don't have the API's code available as well. Not being a C# developer can you please make me understand what is automatic marshalling and how can it be implemented.

            You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

            L 1 Reply Last reply
            0
            • _ _AnsHUMAN_

              I don't have the API's code available as well. Not being a C# developer can you please make me understand what is automatic marshalling and how can it be implemented.

              You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              either do some research, or ask a specific question, or both. calling Win32 API functions is handled rather well at this PInvoke site[^] :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


              _ 1 Reply Last reply
              0
              • L Luc Pattyn

                either do some research, or ask a specific question, or both. calling Win32 API functions is handled rather well at this PInvoke site[^] :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


                _ Offline
                _ Offline
                _AnsHUMAN_
                wrote on last edited by
                #7

                Thanks for your reply. Will prefer investigation ;)

                You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

                1 Reply Last reply
                0
                • _ _AnsHUMAN_

                  Hello Masters, Can you just put some light on which is the best way to invoke function's from a Win32 dll? I have already studied the following ways: Solution A: Create Bridge Functions and Use PInvoke. Solution B: Create a Bridge DLL in Managed C++. If we don’t have the source code for the dll’s this approach would be better. Also do we need to write a wrapper for each and every function a WIN32 dll exposes?

                  You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

                  N Offline
                  N Offline
                  N a v a n e e t h
                  wrote on last edited by
                  #8

                  _AnsHUMAN_ wrote:

                  Create a Bridge DLL in Managed C++. If we don’t have the source code for the dll’s this approach would be better.

                  You are using C++/CLI right? C++/CLI supports C++ Interop and it is more preferable than P/Invoke. So I think Solution B is going to be good.

                  _AnsHUMAN_ wrote:

                  Also do we need to write a wrapper for each and every function a WIN32 dll exposes?

                  I think, you only need to wrap functions that you use. Take a look at Nish's C++/CLI in Action, it covers these topics. :)

                  Navaneeth How to use google | Ask smart questions

                  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