c# - GetWindowText() function is not executing correctly at all times -
i'm writing small application wish url chrome browse.
in order first check if chrome browser open or not use following code:
intptr windowtitletextptr = getforegroundwindow(); stringbuilder windowtitletext = new stringbuilder(); getwindowtext(windowtitletextptr, windowtitletext, 256); // problem ...
i'm using getwindowtext() function windows title text, i'm facing problem there.
if chrome window has no url , new tab have no issues, windowtitletext.tostring() equal new tab - google chrome.
however if open webpage, in case url filled url @ line getwindowtext() get: vs32host.exe has stopped working message window asking me
what's going on?
help!
you should allocate memory within stringbuilder
instance:
stringbuilder windowtitletext = new stringbuilder(); int size = 256; windowtitletext.length = size; // <- memory allocation getwindowtext(windowtitletextptr, windowtitletext, windowtitletext.length); // <- read text allocated memory
Comments
Post a Comment