Calling code from Win32 dll
-
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_
-
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_
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
-
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_
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
-
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
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_
-
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
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_
-
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_
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
-
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
Thanks for your reply. Will prefer investigation ;)
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_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_
_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