C# get main window title of processes on a remote machine

元气小坏坏 提交于 2019-12-08 05:06:45

问题


I am developing a C# program that is run from a server and monitors processes on another set of servers. The processes I am monitoring all have the same exe name, but different windows title names. I am looking for a way to pull the windows title names from these processes remotely.

Basically what i would like to do is the following;

        Process[] processList = Process.GetProcesses("ServerName");
        foreach (Process p in processList)
        {
            try
            {
                Console.WriteLine(p.MainWindowTitle);

            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }

However this is not supported by .NET

Does anyone know of another way?


回答1:


I won't tell you this is the best approach, but it's possible to use it. You could create a simple service (windows service) and install it on each server. You might want to implement auto update functionality and therefore after installation you don't have to reinstall this service app on every machine. And this service app gets processes and associated windows titles (it may be more than one window within single process) and returns it to the machine that queries that information. I think you could use WCF here. And other advantage is that you can add more other functionality more easier.



来源:https://stackoverflow.com/questions/11352618/c-sharp-get-main-window-title-of-processes-on-a-remote-machine

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!