wcslen) or converting from widestring to character-string as indicated here:Ĭ++ Convert string (or char*) to wstring (or wchar_t*) You need to be passing it a wchar_t array and then either working entirely in widestring (e.g. That would explain why you see a memory violation, because UTF-16 wide-chars contain 2 bytes you are effectively telling GetWindowTextW that the buffer can house 14 bytes, when it is actually only 7 bytes long. Note you will potentially overrun the end of the array since the nMaxCount parameter is number of characters, not number of bytes. GetWindowTextW provides output as a unicode widestring. I'm also confused about why did the strstr() function rises an memory violation when printing the output value to the console while just simply reading it doesnt raises any memoy violation GetWindowTextW(foreground, (LPWSTR)window_title, 7) Īnd my build is unicode so that was the problem i had to add that A at the end by why, also why when i get the window text using GetWindowTextW aka GetWindowText one char takes more space, i guess it's because of how i cast it right char window_title In a non-Unicode build, GetWindowText and GetWindowTextA are the same thing. GetWindowText(foreground, (LPWSTR)window_title, 7) Īuto output = strstr(window_title, "FiveM") Īnd got not output, everything was 0, but when i used the function GetWindowTextA() everything worked fine, so i googled some more about this getwindow function and i found this link and i saw this #define GetWindowText GetWindowTextA So i was googling and i found the GetWindowText function. To check if the "FiveM" name appears in the title bar of the window, because usually in this game the title bar also contains updates and so on I was having trouble getting a substring using strstr(a,b)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |