Click here to Skip to main content
15,893,487 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionSHBrowseForFolder() API pb Pin
super_ttd21-Nov-06 0:32
super_ttd21-Nov-06 0:32 
AnswerRe: SHBrowseForFolder() API pb Pin
James R. Twine21-Nov-06 0:50
James R. Twine21-Nov-06 0:50 
GeneralRe: SHBrowseForFolder() API pb Pin
super_ttd21-Nov-06 1:31
super_ttd21-Nov-06 1:31 
AnswerRe: SHBrowseForFolder() API pb Pin
David Crow21-Nov-06 3:26
David Crow21-Nov-06 3:26 
GeneralRe: SHBrowseForFolder() API pb Pin
super_ttd21-Nov-06 3:30
super_ttd21-Nov-06 3:30 
GeneralRe: SHBrowseForFolder() API pb Pin
David Crow21-Nov-06 3:38
David Crow21-Nov-06 3:38 
GeneralRe: SHBrowseForFolder() API pb Pin
super_ttd21-Nov-06 3:39
super_ttd21-Nov-06 3:39 
QuestionReadDirectoryChangesW doesn't get message about deleting whole directory [modified] Pin
rudo3221-Nov-06 0:19
rudo3221-Nov-06 0:19 
Symphton
When I delete directory which contains some files I will not get message FILE_ACTION_REMOVED. This happens int XP professional SP1. I can't install SP2 because some others reasons.
My code
initialization of watching
DirInfo[0].hDir = CreateFile(sDirectory, // pointer to the file name
					FILE_LIST_DIRECTORY,
                    FILE_SHARE_READ |
                    FILE_SHARE_WRITE |
                    FILE_SHARE_DELETE,
                    NULL,
                    OPEN_EXISTING,
                    FILE_FLAG_BACKUP_SEMANTICS |
                    FILE_FLAG_OVERLAPPED,
                    NULL									// file with attributes to copy
					);
	if(DirInfo[0].hDir==INVALID_HANDLE_VALUE)
		return IDS_ERRCREATEFILE;
	hCompPort=0;
	// Set up a key(directory info) for each directory
    hCompPort=CreateIoCompletionPort( DirInfo[0].hDir,
                                      hCompPort,
                                      (DWORD) &DirInfo[0],
                                      0);
	if(!hCompPort)
		return IDS_ERRCREATEIOPORT;

	// Start watching each of the directories of interest
    ReadDirectoryChangesW( DirInfo[0].hDir,
                           DirInfo[0].lpBuffer,
                           MAX_BUFFER,
                           TRUE,
                           FILE_NOTIFY_CHANGE_SECURITY|
							FILE_NOTIFY_CHANGE_CREATION|
							FILE_NOTIFY_CHANGE_LAST_ACCESS|
							FILE_NOTIFY_CHANGE_LAST_WRITE|
							FILE_NOTIFY_CHANGE_SIZE|
							FILE_NOTIFY_CHANGE_ATTRIBUTES|
							FILE_NOTIFY_CHANGE_DIR_NAME|
							FILE_NOTIFY_CHANGE_FILE_NAME,
                           &DirInfo[0].dwBufLength,&DirInfo[0].Overlapped,
                           NULL);

watching loop in other thread
unsigned __stdcall CFileChangeWatch::DoFileChangeWatch(void *_pcFileChangeWatch)
{
	DWORD numBytes;
	DWORD cbOffset;
	LPDIRECTORY_INFO di;
	LPOVERLAPPED lpOverlapped;
	PFILE_NOTIFY_INFORMATION fni;
	CString      szFullFileName;
	CFileChangeWatch *pcFileChangeWatch=(CFileChangeWatch *)_pcFileChangeWatch;
	char sBuff[256];
	CString sPath;

	do
	{
		// Retrieve the directory info for this directory
		// through the completion key
		GetQueuedCompletionStatus( (HANDLE) pcFileChangeWatch->hCompPort,
								   &numBytes,
								   (LPDWORD) &di,
								   &lpOverlapped,
								   INFINITE);
		if ( di )
		{
			fni = (PFILE_NOTIFY_INFORMATION)di->lpBuffer;
			do
			{
				cbOffset = fni->NextEntryOffset;

				szFullFileName=di->lpszDirName;
				szFullFileName=szFullFileName + "\\";
				szFullFileName=szFullFileName+ CString(fni->FileName).Left(fni->FileNameLength / 2);

				//OutputDebugString(szFullFileName);
				//OutputDebugString(" ");

				// test for fdf
				if(!strcmp(szFullFileName.Right(3),"fdf"))
				{

					DBAction 					// classify action
					switch(fni->Action)
					{
						case FILE_ACTION_ADDED:							
														break;
						case FILE_ACTION_REMOVED:
														break;
						case FILE_ACTION_MODIFIED:
							
							break;
						case FILE_ACTION_RENAMED_OLD_NAME:
							
							break;
						case FILE_ACTION_RENAMED_NEW_NAME:
														break;
						default:;
					}


				// next action
				fni = (PFILE_NOTIFY_INFORMATION)((LPBYTE) fni + cbOffset);
			} while( cbOffset );

			// Reissue the watch command
			ReadDirectoryChangesW(	di->hDir,di->lpBuffer,
									MAX_BUFFER,
									TRUE,
									FILE_NOTIFY_CHANGE_SECURITY|
									FILE_NOTIFY_CHANGE_CREATION|
									FILE_NOTIFY_CHANGE_LAST_ACCESS|
									FILE_NOTIFY_CHANGE_LAST_WRITE|
									FILE_NOTIFY_CHANGE_SIZE|
									FILE_NOTIFY_CHANGE_ATTRIBUTES|
									FILE_NOTIFY_CHANGE_DIR_NAME|
									FILE_NOTIFY_CHANGE_FILE_NAME,
									&di->dwBufLength,
									&di->Overlapped,
									NULL);
		}

	} while( di );

	return 0;
};




-- modified at 9:28 Tuesday 21st November, 2006
AnswerRe: ReadDirectoryChangesW doesn't get message about deleting whole directory Pin
Ștefan-Mihai MOGA21-Nov-06 0:30
professionalȘtefan-Mihai MOGA21-Nov-06 0:30 
GeneralRe: ReadDirectoryChangesW doesn't get message about deleting whole directory Pin
rudo3221-Nov-06 1:30
rudo3221-Nov-06 1:30 
AnswerRe: ReadDirectoryChangesW doesn't get message about deleting whole directory Pin
Nibu babu thomas21-Nov-06 0:32
Nibu babu thomas21-Nov-06 0:32 
JokeRe: ReadDirectoryChangesW doesn't get message about deleting whole directory Pin
rudo3221-Nov-06 1:12
rudo3221-Nov-06 1:12 
AnswerRe: ReadDirectoryChangesW doesn't get message about deleting whole directory Pin
toxcct21-Nov-06 1:51
toxcct21-Nov-06 1:51 
Questionnamed pipe Pin
vineeshV21-Nov-06 0:04
vineeshV21-Nov-06 0:04 
AnswerRe: named pipe Pin
Raj Prathap21-Nov-06 0:26
Raj Prathap21-Nov-06 0:26 
AnswerRe: named pipe Pin
harsha_123421-Nov-06 1:13
harsha_123421-Nov-06 1:13 
QuestionCListCtrl Please Help ! Pin
Bravoone_200620-Nov-06 23:59
Bravoone_200620-Nov-06 23:59 
AnswerRe: CListCtrl Please Help ! Pin
Radu Sorin21-Nov-06 1:04
Radu Sorin21-Nov-06 1:04 
AnswerRe: CListCtrl Please Help ! Pin
CPallini21-Nov-06 1:59
mveCPallini21-Nov-06 1:59 
AnswerRe: CListCtrl Please Help ! Pin
toxcct21-Nov-06 3:02
toxcct21-Nov-06 3:02 
QuestionFinding files older than a week Pin
m.dietz20-Nov-06 23:39
m.dietz20-Nov-06 23:39 
QuestionRe: Finding files older than a week Pin
Viorel.21-Nov-06 1:37
Viorel.21-Nov-06 1:37 
AnswerRe: Finding files older than a week Pin
m.dietz21-Nov-06 3:57
m.dietz21-Nov-06 3:57 
QuestionRe: Finding files older than a week Pin
David Crow21-Nov-06 5:10
David Crow21-Nov-06 5:10 
AnswerRe: Finding files older than a week Pin
m.dietz21-Nov-06 20:23
m.dietz21-Nov-06 20:23 

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.