;Autor: Sparkie ;http://www.purebasic.fr/english/viewtopic.php?p=86514#p86514 EnableExplicit #FILE_NOTIFY_CHANGE_FILE_NAME = 1 #FILE_NOTIFY_CHANGE_DIR_NAME = 2 #FILE_NOTIFY_CHANGE_ATTRIBUTES = 4 #FILE_NOTIFY_CHANGE_SIZE = 8 #FILE_NOTIFY_CHANGE_LAST_WRITE = $10 #FILE_NOTIFY_CHANGE_SECURITY = $100 #INVALID_HANDLE_VALUE = - 1 #STATUS_WAIT_0 = 0 #WAIT_OBJECT_0 = #STATUS_WAIT_0 + 0 Define EventID Procedure FFCN(z) Protected hFFCN Protected status hFFCN = FindFirstChangeNotification_("c:\abc\", #False, #FILE_NOTIFY_CHANGE_FILE_NAME) If hFFCN = #INVALID_HANDLE_VALUE MessageRequester("Error", "Invalid FindFirstChangeNotification.") ExitProcess_(0) EndIf While #True status = WaitForSingleObject_(hFFCN, #INFINITE) Select status Case #WAIT_OBJECT_0 MessageRequester("Info", "Change occured in C:\abc\") If FindNextChangeNotification_(hFFCN) = #False MessageRequester("Error", "Invalid FindNextChangeNotification") ExitProcess_(0) EndIf EndSelect Wend EndProcedure If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) ButtonGadget(0, 10, 10, 280, 20, "Create file: c:\abc\Testing.txt") ButtonGadget(1, 10, 50, 280, 20, "Delete file: c:\abc\Testing.txt") CreateThread(@FFCN(),0) Repeat EventID=WaitWindowEvent() If EventID=#PB_Event_Gadget Select EventGadget() Case 0 CreateFile(0, "c:\abc\Testing.txt") CloseFile(0) Case 1 DeleteFile("c:\abc\Testing.txt") EndSelect EndIf Until EventID = #PB_Event_CloseWindow EndIf ; IDE Options = PureBasic 5.31 (Windows - x64) ; CursorPosition = 2 ; Folding = - ; EnableUnicode ; EnableXP ; EnableUser ; EnableCompileCount = 0 ; EnableBuildCount = 0