Click here to Skip to main content
15,890,186 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: File Opening Failed Pin
KingsGambit30-Jun-10 19:20
KingsGambit30-Jun-10 19:20 
GeneralRe: File Opening Failed Pin
T.RATHA KRISHNAN30-Jun-10 19:26
T.RATHA KRISHNAN30-Jun-10 19:26 
GeneralRe: File Opening Failed Pin
KingsGambit30-Jun-10 19:49
KingsGambit30-Jun-10 19:49 
GeneralRe: File Opening Failed Pin
T.RATHA KRISHNAN30-Jun-10 20:00
T.RATHA KRISHNAN30-Jun-10 20:00 
GeneralRe: File Opening Failed Pin
Richard MacCutchan30-Jun-10 21:38
mveRichard MacCutchan30-Jun-10 21:38 
AnswerRe: File Opening Failed Pin
Aescleal30-Jun-10 21:16
Aescleal30-Jun-10 21:16 
AnswerRe: File Opening Failed Pin
David Crow1-Jul-10 4:22
David Crow1-Jul-10 4:22 
QuestionFILE_NOTIFY_CHANGE_SIZE and FindFirstChangeNotification behavior in W7 and XP Pin
auriga1930-Jun-10 12:18
auriga1930-Jun-10 12:18 
Hello,

I'm using a small program that notify me when a file size change inside a directory. The program worked perfect under Win XP, now in Windows 7 the size changes are ignored for long periods and notifications are not in sync with the changes.

At first glance that could be seen as something related to caching/flushing differences between XP and Win 7 but I verified that the file I'm monitoring is being flushed to the disk and is not staying in cache.

I used the command tail -f monitoredfile.txt displaying the file content as it is updated and I was able to see all the changes in real time but my monitor program wasn't reporting any file size change.

This is the monitor program:

#include <windows.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <tchar.h>
    
    void RefreshDirectory(LPTSTR);
    void RefreshTree(LPTSTR);
    void WatchDirectory(LPTSTR);
    
    int _tmain(int argc, TCHAR *argv[])
    {
        if(argc != 2)
        {
            _tprintf(TEXT("Usage: %s <dir>\n"), argv[0]);
            return 1;
        }
    
        WatchDirectory(argv[1]);
    }
    
    void WatchDirectory(LPTSTR lpDir)
    {
       DWORD dwWaitStatus; 
       HANDLE dwChangeHandles[2]; 
       TCHAR lpDrive[4];
       TCHAR lpFile[_MAX_FNAME];
       TCHAR lpExt[_MAX_EXT];
    
       _tsplitpath_s(lpDir, lpDrive, 4, NULL, 0, lpFile, _MAX_FNAME, lpExt, _MAX_EXT);
    
       lpDrive[2] = (TCHAR)'\\';
       lpDrive[3] = (TCHAR)'\0';
    
    // Watch the directory for file size changes. 
    
       dwChangeHandles[0] = FindFirstChangeNotification( 
          lpDir,                         // directory to watch 
          FALSE,                         // do not watch subtree 
          FILE_NOTIFY_CHANGE_SIZE); // watch file size changes 
    
       
    // Change notification is set. Now wait on notification handles
    
       while (TRUE) 
       {  printf("\nWaiting for notification...\n");
    
          dwWaitStatus = WaitForMultipleObjects(1, dwChangeHandles, FALSE, INFINITE); 
    
          switch (dwWaitStatus) 
          { 
             case WAIT_OBJECT_0: 
    
             // A file size changed in the directory.
             // do your processing and restart the notification.
    						 
    						 _tprintf(TEXT("Directory (%s) changed.\n"), lpDir);
    						 
                 if (FindNextChangeNotification(dwChangeHandles[0]) == FALSE)
                 {
                   printf("\n ERROR: FindNextChangeNotification function failed.\n");
                   ExitProcess(GetLastError()); 
                 }
                 break; 
    
             default: 
                printf("\n ERROR: Unhandled dwWaitStatus.\n");
                ExitProcess(GetLastError());
                break;
          }
       }
    }

AnswerRe: FILE_NOTIFY_CHANGE_SIZE and FindFirstChangeNotification behavior in W7 and XP Pin
«_Superman_»30-Jun-10 18:48
professional«_Superman_»30-Jun-10 18:48 
GeneralRe: FILE_NOTIFY_CHANGE_SIZE and FindFirstChangeNotification behavior in W7 and XP Pin
auriga191-Jul-10 5:59
auriga191-Jul-10 5:59 
QuestionRe: FILE_NOTIFY_CHANGE_SIZE and FindFirstChangeNotification behavior in W7 and XP Pin
David Crow1-Jul-10 8:15
David Crow1-Jul-10 8:15 
AnswerRe: FILE_NOTIFY_CHANGE_SIZE and FindFirstChangeNotification behavior in W7 and XP Pin
auriga191-Jul-10 9:22
auriga191-Jul-10 9:22 
QuestionRe: FILE_NOTIFY_CHANGE_SIZE and FindFirstChangeNotification behavior in W7 and XP Pin
David Crow1-Jul-10 10:00
David Crow1-Jul-10 10:00 
AnswerRe: FILE_NOTIFY_CHANGE_SIZE and FindFirstChangeNotification behavior in W7 and XP Pin
auriga191-Jul-10 10:02
auriga191-Jul-10 10:02 
QuestionRe: FILE_NOTIFY_CHANGE_SIZE and FindFirstChangeNotification behavior in W7 and XP Pin
David Crow1-Jul-10 10:23
David Crow1-Jul-10 10:23 
AnswerRe: FILE_NOTIFY_CHANGE_SIZE and FindFirstChangeNotification behavior in W7 and XP Pin
auriga191-Jul-10 10:41
auriga191-Jul-10 10:41 
Questionabout Hook Pin
rockago30-Jun-10 9:48
rockago30-Jun-10 9:48 
AnswerRe: about Hook Pin
Adam Roderick J30-Jun-10 17:55
Adam Roderick J30-Jun-10 17:55 
GeneralRe: about Hook Pin
rockago30-Jun-10 18:36
rockago30-Jun-10 18:36 
QuestionCMDIChildWnd changing size unexpectedly Pin
genush30-Jun-10 6:45
genush30-Jun-10 6:45 
AnswerRe: CMDIChildWnd changing size unexpectedly Pin
Niklas L30-Jun-10 9:31
Niklas L30-Jun-10 9:31 
GeneralRe: CMDIChildWnd changing size unexpectedly Pin
genush2-Jul-10 11:29
genush2-Jul-10 11:29 
QuestionConnect to http server / check if file exists [modified] Pin
ALLERSLIT30-Jun-10 4:40
ALLERSLIT30-Jun-10 4:40 
AnswerRe: Connect to http server / check if file exists Pin
David Crow30-Jun-10 6:03
David Crow30-Jun-10 6:03 
AnswerRe: Connect to http server / check if file exists Pin
Moak30-Jun-10 6:14
Moak30-Jun-10 6:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.