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;
    }


  • 相关阅读:
    回车执行函数
    ajax短信验证码-mvc
    css3背景及字体渐变
    MVC3-表单
    Layout布局
    【leetcode】两数之和
    C语言如何开发简单的插件
    Google Supersonic列存储查询库的介绍、安装、测试
    vm网络设置
    centos升级支持到C++11, gcc4.8.2
  • 原文地址:https://www.cnblogs.com/liujx2019/p/12530981.html
Copyright © 2011-2022 走看看