Hi
How do you directly call a native function exported from a DLL ?
How do you Directly call a Native Function Exported from a DLL
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Jun 27, 2012, 2:06 AM EDT
Example of the DllImport attribute in action:
using System.Runtime.InteropServices; class C { [DllImport("user32.dll")] public static extern int MessageBoxA (int h, string m, string c, int type); public static int Main() { return MessageBoxA(0, "Hello World!", "Caption", 0); } }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 MessageBoxA. For more information, look at the Platform Invoke tutorial in the documentation.
Please refer the below link
http://www.dotnetfunda.com/interview/exam5239-how-do-you-directly-call-a-native-function-exported-from-a-dll.aspx
Thanks