ReadDirectoryChangesW problem

T

Tanuki

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_WRITE,&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.
 
T

Thomas Matthews

Tanuki said:
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_WRITE,&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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,458
Latest member
Chris#

Latest Threads

Top