mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 04:55:39 +02:00
fix crash calling GetWindowTextLength()
This commit is contained in:
parent
c719aee32f
commit
c15ab870ac
1 changed files with 15 additions and 8 deletions
|
@ -1203,15 +1203,22 @@ namespace PersistentWindows.Common
|
||||||
if (use_cache && windowTitle.ContainsKey(hwnd))
|
if (use_cache && windowTitle.ContainsKey(hwnd))
|
||||||
return windowTitle[hwnd];
|
return windowTitle[hwnd];
|
||||||
|
|
||||||
var length = User32.GetWindowTextLength(hwnd);
|
try
|
||||||
if (length > 0)
|
|
||||||
{
|
{
|
||||||
length++;
|
var length = User32.GetWindowTextLength(hwnd);
|
||||||
var title = new StringBuilder(length);
|
if (length > 0)
|
||||||
User32.GetWindowText(hwnd, title, length);
|
{
|
||||||
var t = title.ToString();
|
length++;
|
||||||
t = t.Trim();
|
var title = new StringBuilder(length);
|
||||||
return t;
|
User32.GetWindowText(hwnd, title, length);
|
||||||
|
var t = title.ToString();
|
||||||
|
t = t.Trim();
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//return hwnd.ToString("X8");
|
//return hwnd.ToString("X8");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue