/// Return a `Window` object for the `pid`s main window
Return a `Window` object for the `pid`s main window
Return a ` Window ` object for the ` pid ` s main window
pub fn attach_pid(pid: u32, window_title: &str) -> io::Result<Self> {
        let mut context: (u32, Option<usize>, String) =
            (pid, None, window_title.into());
        unsafe {
            if !EnumWindows(Self::enum_windows_handler,
                    &mut context as *mut _ as usize) {
                // EnumWindows() failed, return out the corresponding error
                return Err(io::Error::last_os_error());
            }
        }
        if let Some(hwnd) = context.1 {
            // Create the window object
            Ok(Window { hwnd })
        } else {
            // Could not find a HWND
            Err(io::Error::new(io::ErrorKind::Other,
                "Could not find HWND for pid"))
        }
    }
pub fn attach_pid ( pid : u32 , window_title : & str ) -> io :: Result < Self > { let mut context : ( u32 , Option < usize > , String ) = ( pid , None , window_title . into ( ) ) ; unsafe { if ! EnumWindows ( Self :: enum_windows_handler , & mut context as * mut _ as usize ) { // EnumWindows() failed, return out the corresponding error return Err ( io :: Error :: last_os_error ( ) ) ; } } if let Some ( hwnd ) = context . 1 { // Create the window object Ok ( Window { hwnd } ) } else { // Could not find a HWND Err ( io :: Error :: new ( io :: ErrorKind :: Other , " " ) ) } }
Return a `Window` object for the `pid`s main window
Return a ` Window ` object for the ` pid ` s main window
pid
u32
window_title
&str