0 Replies Latest reply: Dec 6, 2007 8:56 AM by 843807 RSS

    Windows Access Bridge from C# (WindowsAccessBridge.dll)

    843807
      Hello-

      Does anyone have sample code for how to call into WindowsAccessBridge.dll from C#? I'm able to build, run, and debug through the Ferret and Monkey samples from Visual Studio .NET 2005, but that's native C code.

      I think I've distilled it down to the minimal set of lines required to get started, which I've pasted below, but no calls to "isJavaWindow" will return "true". I've verified the window handle I'm passing in two ways: via Spy++, and by stepping through the Monkey project (it finds the window correctly).

      So am I missing an initialization step? Does anyone have working C# code that wraps the Windows Access Bridge?

      Greatly appreciated. My code follows. Just create a new C# console app and replace the default Program.cs with this to see it go. Or not.



      using System;
      using System.Runtime.InteropServices;

      namespace WABTest
      {
      class Program
      {
      [STAThread]
      static void Main(string[] args)
      {
      DoWABTest();
      }

      [DllImport("kernel32.dll")]
      private static extern IntPtr LoadLibrary(string lpFileName);

      [DllImport("WindowsAccessBridge", CallingConvention = CallingConvention.Cdecl)]
      private extern static void Windows_run();

      [DllImport("WindowsAccessBridge", CallingConvention = CallingConvention.Cdecl)]
      private extern static bool isJavaWindow(IntPtr window);

      static void DoWABTest()
      {
      IntPtr _bridgeInstance = LoadLibrary("WindowsAccessBridge");
      Windows_run();
      bool ijw = isJavaWindow(new IntPtr(0x0006050A));
      }
      }
      }