Using FindFirstChangeNotification() problem

I am new to the win32 C++ language and is having a problem with inplementing 
the above structure, below is the code that i'm using to monitor a 
folder/file exclusively for renaming action:

HANDLE 
ret=FindFirstChangeNotification(dir,true,FILE_NOTIFY_CHANGE_FILE_NAME);

//change notification is set now start monitoring
while(1){
//start wait proccess
DWORD wp = WaitForSingleObject(ret, INFINITE);


    switch(wp)
    {
   case WAIT_OBJECT_0 :
   HANDLE hDir = CreateFile(
    dir,FILE_LIST_DIRECTORY,FILE_SHARE_READ|FILE_SHARE_DELETE,
    NULL, /* security descriptor */
    OPEN_EXISTING, /* how to create */
    FILE_FLAG_BACKUP_SEMANTICS, /* file attributes */
    NULL);

 FILE_NOTIFY_INFORMATION Buffer[1024];
  DWORD BytesReturned;
  while(ReadDirectoryChangesW(
     hDir, /* handle to directory */
     &Buffer, /* read results buffer */
     sizeof(Buffer), /* length of buffer */
     TRUE, /* monitoring option */
     FILE_NOTIFY_CHANGE_FILE_NAME, /* filter conditions */
     &BytesReturned, /* bytes returned */
     NULL, /* overlapped buffer */
    NULL))
     {
     LPTSTR htxt;
     switch(Buffer[0].Action){
     case FILE_ACTION_ADDED: htxt = "The file was added to the directory"; 
break;
      case FILE_ACTION_REMOVED: htxt = "The file was removed from the 
directory"; break;
      case FILE_ACTION_MODIFIED: htxt = "The file was modified. This can be 
a change in the time stamp or attributes."; break;
      case FILE_ACTION_RENAMED_OLD_NAME: htxt = "The file was renamed and 
this is the old name."; break;
      case FILE_ACTION_RENAMED_NEW_NAME: htxt = "The file was renamed and 
this is the new name."; break;
      }
              Application->MessageBox(htxt,"Notification",MB_OK);
           }


     while (!Buffer[i].NextEntryOffset);
    }


        if(FindNextChangeNotification(ret) == FALSE )
                ExitProcess(GetLastError());

            break;
            }
             FindCloseChangeNotification(ret);
            }

When i  run this code, it does nothing, what is meant to happen is for it to 
display a messagebox, stating what has taken place according to the "htxt" 
variable.

Anyone got any ideas? 


0
3/14/2006 1:10:49 PM
vc.mfc 33608 articles. 0 followers. Follow

0 Replies
468 Views

Similar Articles

[PageSpeed] 18

Reply:

Similar Artilces:

Can I delete a file that is in use
I have a malocious file called sdra64.exe it's in my appdata\roaming folder I can't delete it because it isays it s in use by another program How can I set it up so that it is deleted somehow? Thanks I have a malocious file called sdra64.exe it's in my appdata\roaming folder I can't delete it because it isays it s in use by another program How can I set it up so that it is deleted somehow? Thanks You can try using the task manager. Bring up the manager and go to processes and stop it from running. You can try to delete from Safe Mo...

Problems installing Office 2004
I used a trial version of Office 2004 in my MacBook until it expired. I few days ago I bought I licensed Office 2004 - Student and teacher edition and tried to install it in the MacBook. I deleted the previous version by dragging all Office folder to trash. I inserted the CD but could not install using the installer since it did not appear active, so I copied the whole Office folder to the Applications. After this I tried to open an Office application, but no one opened. I tried to remove Office using the removal tool but that also did not open. Any suggestions of what should I do? ASPer...

Replying to Individual in Newsgroup using Outlook, with O.E. as NG reader
I'm using Outlook 2000 sp1 for E-mailing. It's set-up to use Outlook Express 6 as the newsgroup reader (whilst calling itself Outlook Newsreader). I recently wanted to reply to an individual in a thread. Everything seemed to go okay until I checked the 'Sent Items' of Outlook. There was an E-mail to the individual, but none of the text that I'd included was there, only the original newsgroup message. Does anybody know what's going on, how to fix it, or has anybody got any suggestions ? Thanks in Advance Duncan Anderson O/S = Win X/P home sp1 I think this happens be...

HTML spreadsheet problem
Hi, I have created a spreadsheet with Excel and have saved it to a HTML format to be browsed on the web. All works fine but the formatting has not been taken to the HTML version, and I have some fields that have capital letters in the HTML version that are small characters in the Excel format? Not really sure how this is possible? I have the same problem in reverse: internet pages opened in Excel are all fouled up. I think its due to the filters, the components that turn one sort of file into another. Sometimes, updating your filters will work. First, you might want to make sure that you...

CFileDialog drives me insane. Handle Problem ?
Hi, i want to communicate some strange Problems i have with CFileDialog. Hope someone can push in the right direction. 1. Problem: CFileDialog FileDlg(true); INT_PTR nResponse = FileDlg.DoModal(); if (nResponse == IDOK){}else{return;} LPSTR file = FileDlg.GetFileName().GetBuffer(); LPSTR folderPath = FileDlg.GetPathName().GetBuffer(); ULONGLONG fSize = GetFileSizeInByte(fileUrl.GetBuffer()); long GetFileSizeInByte(const char* sFileName) { std::ifstream f; f.open(sFileName, std::ios_base::binary | std::ios_base::in); if (f.eof()) { return 0; } if (!f.good()) { return -1; } ...

OWA logon problem #4
Hello all, here's my problem: Exchange 2003 with SP1 on Win2003 SP1 on a two-node-cluster. If the Clusterresource HTTP-Server restartet (after boot, crash or failover) nobody can logon to OWA because HTTP-Error 500 (Internal Server Error). After an administrator logged on via OWA (yes, he can !) all the other users can use OWA because they can log on now. Any idea ? Regards Ralf ...

Stationery Problem with ImageMaps OL2K / 2K2
Good Evening All, Thanks in advance for your responses. I'm developing a pretty simple stationery for a customer. Basically it's a three row table with images used as headers and footers. The footer image has 7 e-mail addresses on it and I setup a simple inline imagemap to facilitate hyperlinking. All good so far. Note that I developed the page in Notepad, and tested it using Outlook 2000 SR-1. I've sent the e-mail friends and colleagues who also use Outlook, Thunderbird, Eudora, Opera, and others. They everybody was able to utilize the imagemap links... except the custom...

What's the correct procedure to use a CBitmapButton in a dialog (to avoid resouce leaking)?
Hi, I have a CBitmapButton member in a dialog. The problem is that, after exiting my program, there is a cross button staying on my windows 2000's desktop now. The button is exactly the one I used in the dialog. Clicking on it doesn't do anyting. Rebooting the machine doesn't help. The application has been mailed to many customers. Now I expect they'll see this button on their machine but hardly guess that it's caused by my program. In DoDataExchange(), I associate the CBitmapButton member with a push button in the dialog's template. Then in OnInitDialog...

Problem with Outlook e-mail after installing Microsoft Publisher
I have not been able to send e-mails from Outlook after installing Microsoft Publisher. Any suggestions on how to remedy this sotuation? Are you getting an error? Is Outlook working okay through other programs? The Send This Page as Message command is not available when you click Send E-mail on the File menu in Publisher 2003 http://support.microsoft.com/default.aspx?scid=kb;en-us;884425 -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Techblues" <Techblues@discussions.microsoft.com> wrote in message news:CCCE2A75-8...

Problem with a date and concatenation
I got some data out of one of our in house databases and it comes out as 01/022206, for example..a missing second "/" (we need to FIX that damn databse too) I have thousands of these rows, and I need to do some analyses by date, so I need a correct date. So I was going to use text to columns> fixed width and separate the 01/02 from the 2006, then I would concatenate with (replacing the actual contents with the cell name of course) ="01/02"&"/"&"2006" But when I do the text to columns, I get the 2006 but I I don't get 01/02.. I get a...

MX/DNS problem in Exchange
One of my users (on SBS 2003) has intermittent problems sending mail to a particular user elsewhere. After some research, I found out that the recipient's mail mail servers were moved from one domain hosting provider to a new domain provider, but they left their website (xxx) & domain hosting (.com) with the existing domain provider. So... the recipient's domain, abc.com correctly resolves to an IP address at the old provider, 123.com. I can nslookup or ping abc.com, and it correctly resolves to the old IP address. However, the MX records (as tested externally via a websit...

problems compiling xsd in .Net 2003
Hi, I have an .xsd document (Inc_B.xsd) that "includes" two more from the same folder: <xs:include schemaLocation="Inc.xsd" /> <xs:include schemaLocation="Inc_A.xsd" /> They all have the same targetNamespace="http://tempuri.org/Inc.xsd" xmlns:ir="http://tempuri.org/Inc.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" When I try to use xsd utility from .Net command prompt to compile Inc_B.xsd - I receive the following error: Could not find file '\Inc_B folder\Inc.xsd'. I need to assign 'Inc_B.xsd'...

Excel 2000
Hi! *First off:* I have created a spreadsheet that has a dynamic range an data validation. *Next:* i know i can add options to the 'dynamic range' and my dro down menu will add the option to its list. *Problem:* How can I make it so the user can add data into th validated data list/drop down menu rather than having the user addin it into the dynamic range? *Example:*this drop down menu indicates how often a system is updated weekly, monthly, etc. etc... i don't want to restrict it, so i want t make it so they can indicate their own time on how often those update occur. TIA -...

Error when using RMS EDC Settle function
Hello. We run RMSsp2, and use PCCharge PaymntSvr EDC software/First Data processor. PCCharge settles fine, if trying from within RMS, receive error on: 1st attempt: "Invalid Merchant" box error appears. 2nd and subsequent attempts "Invalid Destination Zip" box error appears. Erro occurs withing few seconds of settle attempt, settle progress doesnt go beyond 1/10 of progress meter and this error pops up. Any ideas? Our EDC config is fine and all batches and items are ok in PCCharge. thanks luke ...

problems printing from MS Office Picture Manager
Operating System is Vista. When running MS Office Picture Manager (Office 2007) drop down option pulls up other printers (which work and MS XPS doc writer or install new printer. Install printer works up to and including print test page which prints normally. Like I said it pulls up the other printers and works with everything but MS office picture manager. Is there a way to associate the printer with MSOPM Have you tried right-clicking on any picture and then selecting "open with" method? This would allow you to associate all pictures to open in MSOPM when you cli...

How to use MFC Cstring class in Win32 DLL?
Hello all I am having WIN32 DLL and i have to use CString in it. I tried include <Afx.h> with project setting with both 'use MFC in a static library' as well as 'use MFC in a shared library' option of project setting but firstly i got error fatal error C1189: #error : WINDOWS.H already then i commented #include<windows.h> after that i am getting linking error mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in testdll.obj Debug/testdll.dll : fatal error LNK1169: one or more multiply defined symbols found i tried other options like includi...

Unable to attach an attachment using mail merge
Anyone know how to do an Outlook mail merge and have it sent an attachment to all merged recipents? I put the attachment into the basic outlook e_mail message and when it merges it strips off the attachment. I am using Word as the E-Mail editor and Outlook 2002 SP2 and merging contacts directly from an Outlook Contact folder. ...

Browser Problems in Windows XP
I am having problems getting Microsoft Explorer to work in installations of Windows XP. In some installations it works just fine and in some it will begin to go to the web site and then the window closes with no error. Has anyone experienced this problem before? I can log in with all the user accounts from any windows 98 computer using the same browser version. Thanks for any help. Eric Davison wrote: > I am having problems getting Microsoft Explorer to work in > installations of Windows XP. In some installations it > works just fine and in some it will begin to go to the ...

Problem with CHKDSK
Hi When I run CHKDSK it gets a pass with /i but it hangs at the reboot with /f and /x and it says "CHKDSK is verifying indexes (Stage 2) 0 percent complete" and I have to reboot. I have a Seagate disk drive. I downloaded and ran Seatools for windows and got a pass on Long Drive Self Test. So I can assume that the disk is OK. The utility is read only it does not do any repair. I tried to do an Avast anti-virus scan but it stops before completing the scan and the computer has to be rebooted. Disk cleanup also freezes the computer Any idea of what I could do...

Prevent auto recoloring of chart when using Pivot Table data
I have crated a Pivot tabel with data I want to show in a Chart. My problem is when I refresh data the colours of the "data series" changes. For exaple I want one of my series "OK" always be shown in green colour, but after a refresh of pivot all colours changes. This problem is not only colouring. If I have made changes to my chart so that one series ar plotted on a secondary axis, and I change it to another chart type (e.g. the secondary should be shown as a line instead of column) this also changes when refreshing the data. Most irritating! Anyone that knows how to p...

uninstall from command line using alternate credentials
WinXP SP3. Is there a way to do this? I am trying to find a way for a power user to uninstall a program using the msiexec + uninstall string from the registry using admin account credentials. Alternativly, I have tried to get the user to do a "run as" on the appwiz.cpl file but I get an error. UPDATE: also tried making a shortcut and running as admin but there is still an error with starting the msiexec. It says something like error statring program, it may be disabled or have no associated programs. I checked the windows installer service and it is running. ...

Windows Live ID Problems
I have been using Money 2006 for the last 2 years. Since the online updates stopped as of 9/1/08, I was prompted to download a new version. I downloaded and installed MS Money Plus 2008. When I attempt to log in using my Windows Live ID and password I get the following error: "The email address or password is incorrect. Please try again." I never had this problem with the older version. My Windows Live ID and password work fine on this website and when I go to the main passport website. I am using Windows XP Home Edition, and have been for the last 5+ years. I have re-...

SP3 Problem
Ever since I installed SP3 for Office XP, I have been getting the following error - "A program is trying to access email addresses you have stored in Outlook. Do you want to allow this?" I get this error only when I use Word as my email editor. Hence what is happening is that Outlook thinks that Word is a rogue program trying to send unauthorized emails. My question is, is there a way to prevent this - a whitelist of programs for example? Ajit Disable the PDFMaker addin. (See http://www.slipstick.com/outlook/ol2002sp3.htm#problems for details on how to do this.) "Aj...

Using Microsoft Map in Office XP
How can I add the add-in Microsoft Map to work in Office XP? Thank you for looking. John John MS Map not available with versions 2002 and 2003. MS Map Point is now the application used. Costs about $250.00 US. An alternate is to use MapInfo product(which was the Excel 97 and 2000 product). Very costly at minimum $595.00 US just for upgrade. http://www.mapinfo.com/location/integration But............found this tidbit on the net thanks to Debra Dalgleish. Mystery of the Missing Map Tool: If you believe Microsoft, the Excel Map tool is permanently out of action in Offi...

Problem with KB982526 Microsoft .NET Framework 3.5 SP1 Update for
If I install this update and then reboot my computer freezes right after the boot screen animation... The only way I can get my system back is to boot safe mode and uninstall the update.... Tried this three times, twice thru windows updates, once with the downloaded update files from microsoft I'm running Win7 ultimate x64 HELP! HOW TO Hide an [Optional, non-security] Update... http://www.sevenforums.com/tutorials/24376-windows-update-hide-restore-hidden-updates.html Tim S wrote: > If I install this update and then reboot my computer freezes right after > the...