| | |
Calling Win32 Api from C#
Please support our C# advertiser: Intel Parallel Studio Home
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.
//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); }
Similar Threads
- Help with Win32 API Menu (C)
- Win32 API or OOP using Win32 API (C++)
- Using CopyFile() in win32 api (C++)
- anyone understand win32 api? (C)
- Win32 API Struct (Perl)
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox client clock color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files firefox form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mandelbrot math mouseclick mysql networking operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting richtextbox save saving serialization server setup sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml



