zoukankan      html  css  js  c++  java
  • 文件或文件夹改变后,发信号让系统刷新

    以下方法都无法刷新 Navigation Pane

    /*
    notifychanges.c - Notify win32 subsystem and running programs of globals
    changes such as system environment variables.
    Copyright (c) 2015, Amit Bakshi <ambakshi at gmail dot com>
    All rights reserved.
    Distributed under the BSD License. See included LICENSE for details.
    */

    #ifndef _WIN32_WINNT
    #define _WIN32_WINNT 0x0503
    #endif

    #include <windows.h>
    #include <shlobj.h>
    #include <stdlib.h>

    #ifdef _MSC_VER
    #pragma comment(lib,"user32.lib")
    #pragma comment(lib,"shell32.lib")
    #pragma comment(lib,"kernel32.lib")
    #endif

    int Win32_Notifychanges() {
        DWORD* dwRes;
        const char* lParam = "Environment";
        int timeout = 5, r;

        SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSH, 0, 0); // Works on both dir and file
        // SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0); // Behavior is same as the above
        // SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST, 0, 0); // No effect

         //Both no effects.
        r = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)lParam, SMTO_BLOCK, timeout * 1000, NULL);
        printf("r %d ", r);
        if (r != 0) {
            r = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0, SMTO_BLOCK, timeout * 1000, NULL) != 0;
            printf("r again %d ", r);
        }
        return r;
        return 0;
    }

    int main()
    {
        Win32_Notifychanges();
        return 0;
    }


  • 相关阅读:
    【学习笔记】《架构整洁之道》(2)
    【学习笔记】《架构整洁之道》(1)
    《漫长的婚约》
    My 2020 work schedule
    canal-clientadapter 数据同步实验
    confluence异常关闭恢复
    nginx 添加第三方nginx_upstream_check_module 模块实现健康状态检测
    keepalived问题阐述及配置
    keepalived+lvs 部署
    lvs基础
  • 原文地址:https://www.cnblogs.com/liujx2019/p/12530981.html
Copyright © 2011-2022 走看看