User32.dll:SendMessageTimeout调用正在崩溃Thompson One桌面客户端

时间:2015-07-02 12:11:00

标签: c# winapi pinvoke

我有一个平稳运行的桌面应用程序:当我安装Thompson One Desktop Client时。一旦我安装了Thopson客户端并登录并且桌面应用程序正在运行,桌面应用程序就会尝试获取Thompson客户端句柄的GET_TEXTLENGTH,并且该调用会崩溃Thompson cleint。

以下是相关代码:

    public const int WM_GETTEXTLENGTH = 0x000E;
    public const uint SMTO_ABORTIFHUNG = 0x0002;
   public const uint SMTO_BLOCK = 0x0001;
   public static uint DEFAULT_SENDMESSAGE_TIMEOUT = 250;

   [DllImport("User32.dll", SetLastError = true)]
   public static extern Int32 SendMessageTimeout(UIntPtr hWnd, uint lMsg, UIntPtr wParam, UIntPtr lParam,
       uint fuFlags, uint uTimeout, out UIntPtr lpdwResult);


   public static string GetWindowText(UIntPtr hWnd, int cchMax, out bool bSuccess)
   {
       bSuccess = false;
       StringBuilder text = null;
       UIntPtr lResult = UIntPtr.Zero;
       if (Win32Interop.SendMessageTimeout(hWnd,
           Win32Interop.WM_GETTEXTLENGTH,
           UIntPtr.Zero,
           UIntPtr.Zero,
           Win32Interop.SMTO_ABORTIFHUNG | Win32Interop.SMTO_BLOCK,
           Win32Interop.DEFAULT_SENDMESSAGE_TIMEOUT,
           out lResult) != 0) // This call is crashing Thompson One client.
       {
           // Process 
       }
   }

有人可以帮我弄清楚发生了什么吗?

0 个答案:

没有答案