•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 374,512 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,927 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser:
Though .Net classes are vast and versatile at time you will have to resort to Win32 API calls for accomplishing certain tasks.
The following code shows a simple example of invoking a Win32 api.
The best way to use Win32 apis is to encapsulate it in a class module.
The namespace for COM interop is System.Runtime.InteropServices.
The method name should have DllImport attribute specifying the name of the dll. Here the dll is user32. Other dlls are Gdi and Kernel.
The following code shows a simple example of invoking a Win32 api.
The best way to use Win32 apis is to encapsulate it in a class module.
The namespace for COM interop is System.Runtime.InteropServices.
The method name should have DllImport attribute specifying the name of the dll. Here the dll is user32. Other dlls are Gdi and Kernel.
Last edited : Feb 15th, 2008.
//Class using System.Runtime.InteropServices; namespace SwapMouseEg { class SwapMouse { [DllImport("user32.dll")] public static extern Int32 SwapMouseButton(Int32 bSwap); } } //Form private void btnSwap_Click(object sender, EventArgs e) { SwapMouse.SwapMouseButton(1); } private void btnReset_Click(object sender, EventArgs e) { SwapMouse.SwapMouseButton(0); }
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)