日期:2014-05-17  浏览次数:20910 次

这个问题一直困扰我,让我都阳w了
我用backgroundworker开启了另外一个线程,但是我想调用API函数GetWindowRect,这个函数是基于GUI线程的?
也想过用invoke啦,但是Invoke带参数的形式,是一个object数组,
GetWindowRect的参数有ref关键字,怎么放在ojject数组里?如何解决?



[DllImport("user32.dll")]
    private static extern int GetWindowRect(int hwnd, ref Rect lpRect);
 
    private void bgw_DoWork(object sender, DoWorkEventArgs e)
    {
 
        while (bgw.WorkerSupportsCancellation)
        {
            GetWindowRect(hWnd,ref lpRect);
        }
 

    }

我该怎么调用才能保证功能呢正常?

------解决方案--------------------
System.Drawing.Rectangle lpRect = new Rectangle();
GetWindowRect(hWnd,ref lpRect);