Customize Common Item Dialog SYSTEM-WIDE via hook or registry?

Viewed 51

I am trying to create a file management system for a small business which requires a few pieces of information to save a file. I need to add 3 required text boxes to the common item dialog before allowing save from any application on the computer.

Which direction is recommended to modify the Common Item Dialog system-wide? I am using the Windows Classic Sample CommonFileDialogSDKSample from github to modify the dialog but I don't know how to control the dialog that appears in Word, Excel, Adobe, etc.

------------------ Here are my thoughts and results so far ------------------- From what I understand, the best (only?) way in the past was to use a global hook? But since the new Common Item Dialog is a COM object is this still the right approach?

This makes me think it should be possible to modify the comdlg32.dll: https://www.tenforums.com/tutorials/52655-reset-open-save-common-item-dialog-boxes-windows.html. "Since they're just COM objects with known CLSIDs you might get away with just replacing them by re-registering using their CLSID": https://stackoverflow.com/a/977964/19933151

I have this low level keyboard hook (below) working as a prototype but I'm not sure how to hook the common item dialog. WH_CBT? And then I need to redirect to my custom dialog. Maybe Detours? EasyHook? Am I going to get into trouble with antivirus software if I try to go this route?

#include <Windows.h>
#include <iostream>

LRESULT CALLBACK KBHook(int nCode, WPARAM wParam, LPARAM lParam)
{
    KBDLLHOOKSTRUCT *s = reinterpret_cast<KBDLLHOOKSTRUCT *>(lParam);
    switch (wParam)
    {case WM_KEYDOWN:
        char c = MapVirtualKey(s->vkCode, MAPVK_VK_TO_CHAR);
        std::cout << c << std::endl;
        break;
    }
    return CallNextHookEx(NULL, nCode, wParam, lParam);
}

int main()
{
    std::cout << "Hello, World!" << std::endl;

    HHOOK kbd = SetWindowsHookEx(WH_KEYBOARD_LL, &KBHook, 0, 0);

    MSG message;
    while (GetMessage(&message, NULL, NULL, NULL) > 0)
    {
        TranslateMessage(&message);
        DispatchMessage(&message);
    }

    UnhookWindowsHookEx(kbd);

    return 0;
}

My background is data science via python so windows development is a new world to me and any links or hints are appreciated. Thank you.

0 Answers
Related