0

for example this is a small c script i found here

#include <windows.h>
#include <ShlObj.h>

const char folderpath[] = "C:\\Your-Folder";

int main() {
  SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH, folderPath, NULL);
}

how can write something similar in python?

humantrash
  • 63
  • 6
  • Beware, not to forget *argtypes* and *restype*: [\[SO\]: C function called from Python via ctypes returns incorrect value (@CristiFati's answer)](https://stackoverflow.com/questions/58610333/c-function-called-from-python-via-ctypes-returns-incorrect-value/58611011#58611011). – CristiFati Sep 09 '21 at 01:20

1 Answers1

3

i found this using ctypes

    import ctypes
    shell32 = ctypes.OleDLL('shell32')
    shell32.SHChangeNotify.restype = None
    event = SHCNE_ASSOCCHANGED = 0x08000000
    flags = SHCNF_IDLIST = 0x0000
    shell32.SHChangeNotify(event, flags, None, None)
          

when used the file explorer refreshes but it takes a minute to update the folders, idk if its working or not ...

humantrash
  • 63
  • 6