Excel催化剂开源第47波-Excel与PowerBIDeskTop互通互联之第一篇( 八 )

static extern bool EnumThreadWindows(int dwThreadId, EnumThreadDelegate lpfn,

IntPtr lParam);

private static IEnumerable EnumerateProcessWindowHandles(int processId)

{

var handles = new List();

foreach (ProcessThread thread in Process.GetProcessById(processId).Threads)

EnumThreadWindows(thread.Id,

(hWnd, lParam) => { handles.Add(hWnd); return true; }, IntPtr.Zero);

return handles;

}

private const uint WM_GETTEXT = 0x000D;

[DllImport("user32.dll", CharSet = CharSet.Auto)]

static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam,

推荐阅读