gpt4 book ai didi

c# - Teamviewer 停止工作 GetWindowText (User32.dll) 函数

转载 作者:行者123 更新时间:2023-12-04 08:45:03 25 4
gpt4 key购买 nike

我开发了一个访问 user32.dll 的 C# 代码,它使用 GetWindowText 函数。在 Windows 7 上卸载 Teamviewer 时,代码运行正常。
但是如果你安装了 Teamviewer,代码就不能用 GetWindowText 函数检索窗口中控件的文本。代码如下。我怎么解决这个问题 ?

     [DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr FindWindowExW(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass,
string lpszWindow);

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr GetWindowText(IntPtr hwndParent, StringBuilder Wintxt, int txtsize);


public void CloseWin(string param)
{
try
{
IntPtr hwnD = FindWindowExW(IntPtr.Zero, IntPtr.Zero, "CabinetWClass", null);
IntPtr hwnD2 = FindWindowExW(hwDvar, IntPtr.Zero, "WorkerW", null);
IntPtr hwnD3 = FindWindowExW(hwnD2, IntPtr.Zero, "ReBarWindow32", null);
IntPtr hwnD4 = FindWindowExW(hwnD3, IntPtr.Zero, "Address Band Root", null);
IntPtr hwnD5 = FindWindowExW(hwnD4, IntPtr.Zero, "msctls_progress32", null);
IntPtr hwnD6 = FindWindowExW(hwnD5, IntPtr.Zero, "Breadcrumb Parent", null);
IntPtr hwnD7 = FindWindowExW(hwnD6, IntPtr.Zero, "ToolbarWindow32", null);
StringBuilder sb = new StringBuilder(255);
GetWindowText(hwnD7, sb, 255);

最佳答案

嗯,我已经解决了这个问题。我还通过类名 #32770 调用具有 FindWindowEx 函数的对话框文件类。
Teamviewer(TV) 快速支持用户界面也使用此类类型。当我运行我的代码时,会对 TV 的界面和工作 user32 功能块进行干预。
为了解决这个问题,我用类名和控件名调用了 FindWindow 函数,这样就不需要对电视进行干预,问题就解决了。

关于c# - Teamviewer 停止工作 GetWindowText (User32.dll) 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64366747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com