C# 更改另一个正在运行的应用程序窗口的属性
如果我有一个正在运行的程序的 IntPtr,有什么方法可以更改该窗口的属性——例如:FormBorderStyle、ShowInTaskbar 甚至 BackColor 等属性?
我对 C# 还很陌生,我真的很好奇这样的事情是否可能。
衷心感谢您的时间和帮助!
If I have a IntPtr of a running program, is there any way to change properties about that window--- for instance properties like: FormBorderStyle, ShowInTaskbar and maybe even BackColor?
Im pretty new to C# and am really curious if such a thing is even possible.
Thanks kindly for your time and help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,您不能直接操作另一个进程窗口的托管属性。然而,通过一些技巧你就可以实现这一点。
您需要做的是将一段托管代码注入到正在运行的进程中,然后这段注入的代码将负责实际操作该进程中托管窗口/控件的属性。
与其重复大量信息,不如看看这篇旧的代码项目文章,它几乎实现了您想要的目标。请记住,这仅用于管理另一个 .NET 进程中托管窗口的属性,并且您可能会遇到不同版本的 .NET 问题。
http://www.codeproject.com/KB/dotnet/wfspy.aspx
No, you cannot directly manipulate the managed properties of another process' windows. However, with a little trickery you can achieve this.
What you will need to do is inject a piece of managed code into the running process this piece of injected code will then be responsible for actually manipulating the properties of the managed windows/controls in that process.
Rather than regurgitate a lot of information, take a look at this old codeproject article which achieves pretty much what it sounds like you are looking for. Keep in mind that this is only for managing the proprieties of managed windows in another .NET process and you might have issues with different versions of .NET.
http://www.codeproject.com/KB/dotnet/wfspy.aspx