Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detecting files in a folder
Message
 
À
13/07/2003 21:23:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00809703
Message ID:
00809774
Vues:
35
This message has been marked as the solution to the initial question of the thread.
You can use this code as starting point:
* Usage:
* WaitForFileChanges("C:\")

#define WAIT_OBJECT_0	0
#define INVALID_HANDLE_VALUE	-1
#define INFINITE	0xFFFFFFFF  && Infinite timeout

#define FILE_NOTIFY_CHANGE_FILE_NAME    0x00000001   
#define FILE_NOTIFY_CHANGE_DIR_NAME     0x00000002   
#define FILE_NOTIFY_CHANGE_ATTRIBUTES   0x00000004   
#define FILE_NOTIFY_CHANGE_SIZE         0x00000008   
#define FILE_NOTIFY_CHANGE_LAST_WRITE   0x00000010   
#define FILE_NOTIFY_CHANGE_LAST_ACCESS  0x00000020   
#define FILE_NOTIFY_CHANGE_CREATION     0x00000040   
#define FILE_NOTIFY_CHANGE_SECURITY     0x00000100   

Procedure WaitForFileChanges(strPath)
DECLARE Long FindFirstChangeNotification IN WIN32API ;
	String PathName, Long bWatchSubTree, Long dwNotifyFilter
DECLARE Long WaitForSingleObject IN WIN32API ;
	Long hHandle, Long dwMilliseconds

LOCAL dwChangeHandle, dwWaitStatus
dwChangeHandle = FindFirstChangeNotification( ;
	strPath, ;							&& directory to watch 
	.F., ;							&& do not watch the subtree 
	FILE_NOTIFY_CHANGE_FILE_NAME)	&& watch file name changes 
 
If (dwChangeHandle = INVALID_HANDLE_VALUE)
	ERROR "FindFirstChangeNotification failed."
Else
	&& Wait for notification.
	dwWaitStatus = WaitForSingleObject(dwChangeHandle, INFINITE)
	If dwWaitStatus = WAIT_OBJECT_0
		&& Process changes here
		MESSAGEBOX("Some files were changed in " + strPath + " folder.")
	EndIf
ENDIF
>Hi All,
>
>I have to detect when a file is inserted in a folder by means of a scanner. When this happens, the picture have to be shown in a image control automatically. Any ideas?
>
>Thanks in advance.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform