sqlbaseguptateamdeveloper

VTI71.DLL Give error du0x80004005 in c# project


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,


Solution

  • 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.