| | |
Calling Win32 Api from C#
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
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 algorithm animation array bitmap box c# check checkbox client combobox control conversion csharp customactiondata database datagrid datagridview dataset datastructure date/time datetime datetimepicker degrees directrobot dll draganddrop drawing encryption enum excel file filename files form format forms function gdi+ gis gtk hash image input install java label list mandelbrot math mouseclick mp3 mysql native operator outlook2003 packaging path photoshop picturebox pixelinversion pixelminversion post print process programming radians regex remoting richtextbox safari server sleep snooze socket sql statistics string table tables tcp text textbox thread time timer treeview update usercontrol usercontrols validation visualstudio webbrowser webcam wfa wia winforms wpf xml



