Generate mouse/keyboard events from your mouse.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
interception/MainApp/MouseDll.cs

37 lines
1.1 KiB

using System ;
using System.Runtime.InteropServices ;
namespace MouseInterception
{
class MouseDll
{
// NOTE: The first place DLL's are loaded from are the application directory.
private const string DLL_NAME = "mouse.dll" ;
[DllImport( @DLL_NAME , CallingConvention=CallingConvention.Cdecl )]
[return: MarshalAs(UnmanagedType.BStr)]
private static extern string open_api( int initConsole ) ;
[DllImport( @DLL_NAME , CallingConvention=CallingConvention.Cdecl )]
[return: MarshalAs(UnmanagedType.BStr)]
private static extern string close_api() ;
public MouseDll( bool initConsole )
{
// open the mouse API
string errorMsg = open_api( initConsole ? 1 : 0 ) ;
if ( errorMsg != null )
throw new Exception( errorMsg ) ;
}
~MouseDll()
{
// close the mouse API
string errorMsg = close_api() ;
if ( errorMsg != null )
throw new Exception( errorMsg ) ;
}
}
}