我正在尝试自动化 Gupta 的团队开发人员控制,如中所述
我下载了Team Developer 7.1的 32 位试用版
[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();
}
}
但是给我以下错误:
System.Runtime.InteropServices.SEHException (0x80004005):外部组件已引发异常。
请建议我如何解决此错误。在 C# 中使用 Gupta 的 dll 进行自动化是否正确?
谢谢,