Good day! There is a task to find a window in WINDOWS, and attach this window to the UI (WPF). I use already working library which worked under WIN7. Now I write under WIN10 and get an error.
There is a code:
[DllImport("user32.dll", SetLastError = true)] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll", SetLastError = true)] public static extern IntPtr SetParent(IntPtr hwndChild, IntPtr hwndNewParent); [DllImport("user32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, int x, int y, int cx, int cy, SetWindowPosFlags uFlags); [DllImport("user32.dll")] public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool MoveWindow(IntPtr hwnd, int x, int y, int width, int height, bool repaint); m_hwnd = FindWindow(null, ExternalWindowName); if (m_hwnd == (IntPtr)0) return; IntPtr prn = SetParent(m_hwnd, this.Handle); //prn == 0 // GetLastError() возырвщает код ошибки 5.. What can be wrong?
Thank..