0

I am try to automate Gupta's Team Developer control as mention in

Centura Gupta Team Developer Automation Possibility

I download 32-bit trial version of Team Developer 7.1

[DllImport("user32.dll")]
        static extern IntPtr WindowFromPoint(System.Drawing.Point p);     

        [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        static extern long GetClassName(IntPtr hwnd, StringBuilder lpClassName, long nMaxCount);

        const string guptadllpath = @"C:\program files (x86)\gupta\team developer 7.1\VTI71.DLL";        
        [DllImport(guptadllpath)]
        extern static int VisTblFindString(IntPtr hwndTable, int lStartRow, IntPtr hwndColumn, string lpctszSearchFor);

        IntPtr _wndFromPoint;
        private void MainForm_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                Cursor.Current = Cursors.Default;
                Point p = PointToScreen(e.Location);

                _wndFromPoint = WindowFromPoint(p);

                StringBuilder classText = new StringBuilder(256);
                GetClassName(_wndFromPoint, classText, 256);

                listBox1.Items.Add("Class: " + classText);

                int a = VisTblFindString(_wndFromPoint, 0, IntPtr.Zero, "Pat");

                this.Text = a.ToString();
            }
        }

But give me below error:

System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.

My sample application isenter image description here

Please suggest me how to resolve this error. Is it correct way to use Gupta's dll in c# for automate?

Thanks,

mahen
  • 165
  • 3
  • 16

2 Answers2

1

Calling VisTblFindString(..) from outside won't work. Even though the function takes a window handle as a parameter this will only work from inside the "grid-application". The reason is that one process cannot peek into the memory of another process (ok you can use GetWindowText(..) but this is not applicable here since in a grid not every cell is a distinct window).

You have to set up some interprocess-communication. Unfortunately in gupta grid there are no built-in functions that support this. The only way I see is that you have to modify the grid-application (not sure if you control the source code of it). If you have the possibility to modify it then you can implement automation e.g. via Windows messages.

  • How to create bridge between C#(any other application) and TD application? first i want to try with sample application. – mahen Aug 31 '18 at 10:51
  • As I already stated you can exchange data via Windows messages. It's easy to implement and works with all other applications. To do this, you have to implement kind of an API in the gupta application so you can expose the functionality you need to automate. – Thomas Uttendorfer Aug 31 '18 at 11:25
  • I made an example in TD community forum: http://forum.tdcommunity.net/viewtopic.php?f=6&t=45971 – Thomas Uttendorfer Aug 31 '18 at 12:18
  • Can u help me to covert int C# dll? – mahen Sep 01 '18 at 06:00
  • Built one in C# with VS 2017. See here: http://forum.tdcommunity.net/viewtopic.php?f=6&t=45971 – Thomas Uttendorfer Sep 04 '18 at 08:13
0

I dont know c# from a bar of soap - but if you are using the dll outside of TeamDeveloper, it could be the way you have imported it , or you haven't registered the dll, or you dont have a license to use it outside of TeamDeveloper , or you should be using the 64bit version. A Trial license may not cut it. But I'm just guessing here.

Steve Leighton
  • 790
  • 5
  • 15