InterviewSolution
| 1. |
How Do You Directly Call A Native Function Exported From A Dll? |
|
Answer» Here’s a quick example of the DllImport attribute in action: using System.Runtime.InteropServices; This example shows the minimum REQUIREMENTS for declaring a C# method that is IMPLEMENTED in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of Message BoxA. For more information, look at the Platform Invoke tutorial in the documentation. Here’s a quick example of the DllImport attribute in action: using System.Runtime.InteropServices; This example shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of Message BoxA. For more information, look at the Platform Invoke tutorial in the documentation. |
|