2021年3月22日星期一

How to get the names of programs parented to my WinForm?

I've got a WinForm that parents a program (ex. Google Chrome) to it, so that it runs "inside" the Windows Form. It's using the following code to parent "appWin1" to my Form. I'm trying to be able to find the MainWindowTitle of all the programs that are parented to my form, so I can display their name on a label. The code I have for starting the program does work as it should. I've searched around for an answer for a couple hours, and can't seem to find much on it.

ProcessStartInfo ps1 = new ProcessStartInfo("C:/Users/Jacob/AppData/Roaming/Spotify/Spotify.exe");  ps1.WindowStyle = ProcessWindowStyle.Minimized;  Process p1 = Process.Start(ps1);  Thread.Sleep(1000); // Allow the process to open it's window  appWin1 = p1.MainWindowHandle;  spotify = p1;  // Put it into this form  SetParent(appWin1, this.Handle);  // Move the window to overlay it on this window  MoveWindow(appWin1, 0, 70, this.Width / 2, this.Height/2, true);  
https://stackoverflow.com/questions/66752594/how-to-get-the-names-of-programs-parented-to-my-winform March 23, 2021 at 03:24AM

没有评论:

发表评论