Relative Content

Tag Archive for c++winapi

ReadDirectoryChangesW: no immediate FILE_ACTION_MODIFIED on writes, waits for file handle being closed or opened on the file

I am currently trying to use ReadDirectoryChangesW() to listen for filesystem events on Windows in a directory. In general this works, but I’ve run into an issue: when something just writes to a file (using e.g. WriteFile) no event will be triggered immediately. Instead the event will only be triggered once the file is either closed by the writer, or someone opens a new handle for the same file (assuming that sharing is enabled), but the write itself doesn’t cause the event to trigger, even though the file is in fact written. (Also, this doesn’t even trigger even after a reasonable wait time – if nobody opens and/or closes a file handle for that file after a write operation, no event will be generated at all.)

Is it safe to UnregisterWindowClassEx() inside the message loop?

I am making a little self-contained Dialog class and can’t find any documentation on UnregisterWindowClassEx() regarding when it’s safe to call this function. According to the documentation, you must destroy all windows created with this class before calling this function: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-unregisterclassa

Set mouse position for another window

I want to make autoclicker, that is able to click on specific window, f.e. I am playing some game on full screen and I have an opened app, that I need autoclicker to click on. I want to click on it without closing the game.

WM_HOTKEY Message Not Triggering Window Resize in WinMain Message Loop

#ifndef UNICODE #define UNICODE #endif #define HOTKEY_REG_ERR -10 #define HOTKEY_DEC_ID 1 #define HOTKEY_INC_ID 2 #define HOTKEY_CEN_ID 3 #define WND_CHANGE_SIZE 50 #include <windows.h> LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK WindowProcAlt(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); SHORT ResizeWindow(HWND hwnd, int widthChange, int heightChange); int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, […]