Combine 32- and 64bit DLLs in one program

On 64-bit Windows 64-bit processes can not use 32-bit DLLs and 32-bit processes can’t use 64-bit DLLs. Microsoft has documented this: On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL). Additionally, a 32-bit process cannot load a 64-bit DLL. You would need a 32-bit process that communicates with the 32-bit DLL … Read more

Win32: Bring a window to top

try this,it is said coming from M$ HWND hCurWnd = ::GetForegroundWindow(); DWORD dwMyID = ::GetCurrentThreadId(); DWORD dwCurID = ::GetWindowThreadProcessId(hCurWnd, NULL); ::AttachThreadInput(dwCurID, dwMyID, TRUE); ::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); ::SetWindowPos(m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE); ::SetForegroundWindow(m_hWnd); ::SetFocus(m_hWnd); ::SetActiveWindow(m_hWnd); ::AttachThreadInput(dwCurID, dwMyID, FALSE); In order to bring a window … Read more

Is a memory barrier required to read a value that is atomically modified?

No, you don’t need barriers, but your code is broken anyway if readers and writers call these functions in different threads. Especially if a reader calls the read function in a loop. TL:DR: use C++11 std::atomic<long> m_value with return m_value++ in the increment and return m_value in the reader. That will give you sequential consistency … Read more

Get key press in windows console

If stuff like control and alt keys, these are virtual key strokes, they are supplements to characters. You will need to use ReadConsoleInput. But you will get it all, the mouse also. So you really need to filter and return a structure from the call so you know if it is the likes of ctrl-A … Read more

Create shortcut with Unicode character

You can tell what goes wrong with the debugger. Inspect “shortcut” in the debugger and note that your Hindi name has been replaced by question marks. Which produces an invalid filename and triggers the exception. You are using an ancient scripting support library that’s just not capable of handling the string. You’ll need to use … Read more