By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,305 Members | 1,822 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

ReadDirectoryChangesW problem

P: n/a
Hi All:

I am currently writing a VC++ 6 program to detect file addition to a
specific directory. I am using ReadDirectoryChangesW to detect the
changes and I am running the detection mechanism as a working thread.

My code is as follows:

//*****************************

HANDLE hDir = CreateFile(directoryName, // pointer to the file name,
directoryName is a CString for the directory to be monitored
FILE_LIST_DIRECTORY, // access (read/write) mode
FILE_SHARE_READ|FILE_SHARE_DELETE, // share mode
NULL, // security descriptor
OPEN_EXISTING, // how to create
FILE_FLAG_BACKUP_SEMANTICS, // file attributes
NULL // file with attributes
to copy
);

FILE_NOTIFY_INFORMATION Buffer[1024];
DWORD BytesReturned;

while (ReadDirectoryChangesW (
hDir,&Buffer,1024,TRUE,FILE_NOTIFY_CHANGE_LAST_WRI TE,&BytesReturned,NULL,NULL))
{

// do required tasks for file addition here

}

//************************
However, I kept having the compilation error of
error C2065 : 'ReadDirectoryChangesW' : undeclared identifier

Could someone please kindly enligten me on this? Thank you very much.
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Tanuki wrote:
Hi All:

I am currently writing a VC++ 6 program to detect file addition to a
specific directory. I am using ReadDirectoryChangesW to detect the
changes and I am running the detection mechanism as a working thread.

My code is as follows:

//*****************************

HANDLE hDir = CreateFile(directoryName, // pointer to the file name,
directoryName is a CString for the directory to be monitored
FILE_LIST_DIRECTORY, // access (read/write) mode
FILE_SHARE_READ|FILE_SHARE_DELETE, // share mode
NULL, // security descriptor
OPEN_EXISTING, // how to create
FILE_FLAG_BACKUP_SEMANTICS, // file attributes
NULL // file with attributes
to copy
);

FILE_NOTIFY_INFORMATION Buffer[1024];
DWORD BytesReturned;

while (ReadDirectoryChangesW (
hDir,&Buffer,1024,TRUE,FILE_NOTIFY_CHANGE_LAST_WRI TE,&BytesReturned,NULL,NULL))
{

// do required tasks for file addition here

}

//************************
However, I kept having the compilation error of
error C2065 : 'ReadDirectoryChangesW' : undeclared identifier

Could someone please kindly enligten me on this? Thank you very much.


It's probably because you didn't supply a header file.
When I compile this using Borland C++ Builder and
GNU gcc, I get a lot more "undeclared identifiers".

Since you are using platform specific function calls you
should post this in a Windows or Visual C++ newsgroup.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.