
Is it acceptable to undefine Windows API macros (e.g. If you want to create a library for future use with an intentional name clash, probably no. If you have the time to do that as an exercise, probably (there should be a lot of effort involved). I have not completed this but want to make my own template library for wrapping the Win32 API to make it compatible with std::string/std::wstring. ::GetWindowTextA(hWnd, buffer.data(), len) Įxample Usage std::basic_string text = GetWindowText(hWnd) Return std::basic_string(buffer.begin(), buffer.end()) ::GetWindowTextW(hWnd, buffer.data(), len) Std::size_t len = GetWindowTextLength(hWnd)+1 Template std::basic_string GetWindowText(HWND hWnd) Template int GetWindowTextLength(HWND hWnd)

I prefer to deal directly with the Windows API I just want to make it easier to work with std::basic_string. Note: Please don't provide answers like "why don't you just use WTL?" or "just use MFC". getWindowText or GetWindowString as opposded to GetWindowText)? I prefer not to change the names. Is there perhaps a better way to do this besides changing the name scheme (e.g.Is it acceptable to undefine Windows API macros (e.g.Here's a sample of what I've worked with so far. When checking the debug output after launching the app and pressing Button2 I consistently get:Īfter pressing Button1 and then pressing Button2 again I get:Įxception thrown at 0x00007FFA38A96F6C in MFCApplication3.exe: 0xC0000005: Access violation executing location 0x00007FFA38A96F6C.Īfter uninstalling KB5002226 I consistently get the first set of window titles.I have not completed this but want to make my own template library for wrapping the Win32 API to make it compatible with std::string/std::wstring. ::EnumWindows(EnumWindowsCallback, dwMyAppProId) StrWinProId.Format(_T("Process ID: %d \n"), dwMyAppProId) GetWindowThreadProcessId(hwnd, &dwMyAppProId) Void CMFCApplication3Dlg::OnBnClickedButton2() OutputDebugString(_T("Window Title: ") + strTitle + _T("\n")) ::GetWindowText(hwnd, strTitle.GetBuffer(64), 64) GetWindowThreadProcessId(hwnd, &dwWinProId) If (!db.OpenEx(_T("DSN=Test"), CDatabase::noOdbcDialog))īOOL CALLBACK EnumWindowsCallback(HWND hwnd, LPARAM lParam) Void CMFCApplication3Dlg::OnBnClickedButton1()

This issue is only present where KB5002226 is installed. I have created a new C++ MFC application and am getting an issue whereby if I call GetWindowText on the child windows of my app after a database connection has been opened, the app will throw a Access Violation exception.
