Click here to Skip to main content
15,919,898 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: start a html help file (.chm) Pin
zxc8913-Apr-06 20:19
zxc8913-Apr-06 20:19 
Questionmonitoring and selecting root directory and report changes in that directory Pin
keerthikaaa13-Apr-06 0:20
keerthikaaa13-Apr-06 0:20 
AnswerRe: monitoring and selecting root directory and report changes in that directory Pin
Rage13-Apr-06 1:31
professionalRage13-Apr-06 1:31 
AnswerRe: monitoring and selecting root directory and report changes in that directory Pin
David Crow13-Apr-06 2:55
David Crow13-Apr-06 2:55 
AnswerRe: monitoring and selecting root directory and report changes in that directory Pin
Hamid_RT13-Apr-06 4:28
Hamid_RT13-Apr-06 4:28 
GeneralRe: monitoring and selecting root directory and report changes in that directory Pin
keerthikaaa13-Apr-06 20:47
keerthikaaa13-Apr-06 20:47 
GeneralRe: monitoring and selecting root directory and report changes in that directory Pin
David Crow14-Apr-06 2:15
David Crow14-Apr-06 2:15 
GeneralRe: monitoring and selecting root directory and report changes in that directory Pin
keerthikaaa14-Apr-06 21:38
keerthikaaa14-Apr-06 21:38 
hai DavidCrow

here i am sending u the code

<void ThreadRoute1( void* arg )
{
USES_CONVERSION;


HANDLE hDir = CreateFile(m_sResults, // pointer to the file name
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, // handle to directory
&Buffer, // read results buffer
sizeof(Buffer), // length of buffer
TRUE, // monitoring option
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, // filter conditions
&BytesReturned, // bytes returned
NULL, // overlapped buffer
NULL// completion routine
))
{
CTime tm = CTime::GetCurrentTime();

CString helper_txt;

switch(Buffer[0].Action)
{
case FILE_ACTION_ADDED: helper_txt = "The file was added to the directory"; break;
case FILE_ACTION_REMOVED: helper_txt = "The file was removed from the directory"; break;
case FILE_ACTION_MODIFIED: helper_txt = "The file was modified. This can be a change in the time stamp or attributes."; break;
case FILE_ACTION_RENAMED_OLD_NAME: helper_txt = "The file was renamed and this is the old name."; break;
case FILE_ACTION_RENAMED_NEW_NAME: helper_txt = "The file was renamed and this is the new name."; break;
}
int i=0;
do
{
m_Sec.Lock();
int item = pList1->InsertItem(pList1->GetItemCount(), CString(Buffer[i].FileName).Left(Buffer[i].FileNameLength / 2) + " - " + helper_txt );

pList1->SetItemText(item, 1, tm.Format("%Y/%m/%d/ - %H:%M:%S"));
i++;
m_Sec.Unlock();
}
while (!Buffer[i].NextEntryOffset);
}
}




void CFileSpyView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
pList1 = &m_List1;


m_List1.InsertColumn(0, CString("Path"), LVCFMT_LEFT, 100, 0 );

m_List1.InsertColumn(2, CString("Date/Time occured"), LVCFMT_LEFT, 100, 1 );



}

oid CFileSpyView::OnBrowse()
{
// TODO: Add your control notification handler code here

BROWSEINFO bi;
TCHAR m_DisplayName[MAX_PATH];
m_DisplayName[0]='\0';
memset(&bi, 0x00, sizeof(bi));
bi.hwndOwner = this->m_hWnd;
bi.pszDisplayName = m_DisplayName;

bi.ulFlags = BIF_EDITBOX;

LPITEMIDLIST pidl = SHBrowseForFolder(&bi);


if (pidl)
SHGetPathFromIDList(pidl, m_DisplayName);

//GetDlgItem(IDC_EDIT)->SetWindowText(m_DisplayName);
// UpdateData(TRUE);
m_sResults=m_DisplayName;
UpdateData(FALSE);
Dir=m_sResults;

}
void CFileSpyView::OnBstart()
{
// TODO: Add your control notification handler code here

_beginthread( ThreadRoute1, 0, 0 );

}

void CFileSpyView::OnBstop()
{
// TODO: Add your control notification handler code here
_endthread();

}
>


here when i click the browse button a dailog opens to select adirectory and when when i click the start button the threads starts by monitoring the selceted directory and thread stops when i click the stop button.

the selected directory path i have stored in the edit box variable and i have used it to create the directory in the thread .But i am not able to get that directory monitored.

when i place a "c:\\"in the directory place instead of variable i can get only the specified path monitored.

i want the path which i have selected to be monitored.

Thanks in advance

Smile | :)
QuestionRe: monitoring and selecting root directory and report changes in that directory Pin
David Crow17-Apr-06 3:10
David Crow17-Apr-06 3:10 
QuestionFTP - Resume Pin
racing5713-Apr-06 0:08
racing5713-Apr-06 0:08 
Questionany on explain plz how to monitor the registry Pin
kiranin13-Apr-06 0:05
kiranin13-Apr-06 0:05 
AnswerRe: any on explain plz how to monitor the registry Pin
Rage13-Apr-06 1:25
professionalRage13-Apr-06 1:25 
AnswerRe: any on explain plz how to monitor the registry Pin
David Crow13-Apr-06 3:03
David Crow13-Apr-06 3:03 
QuestionWrapper to function with varargs Pin
Kri512-Apr-06 23:50
Kri512-Apr-06 23:50 
AnswerRe: Wrapper to function with varargs Pin
Rage13-Apr-06 1:36
professionalRage13-Apr-06 1:36 
GeneralRe: Wrapper to function with varargs Pin
Kri513-Apr-06 3:04
Kri513-Apr-06 3:04 
AnswerRe: Wrapper to function with varargs Pin
Chris Losinger13-Apr-06 4:42
professionalChris Losinger13-Apr-06 4:42 
QuestionDATETIMEPICKER Flat Pin
mikobi12-Apr-06 23:47
mikobi12-Apr-06 23:47 
AnswerRe: DATETIMEPICKER Flat Pin
Branislav14-Apr-06 0:35
Branislav14-Apr-06 0:35 
GeneralRe: DATETIMEPICKER Flat Pin
mikobi14-Apr-06 21:26
mikobi14-Apr-06 21:26 
QuestionQuality of FAX Pin
aasstt12-Apr-06 23:21
aasstt12-Apr-06 23:21 
Questionconverting client code from .cpp to .c Pin
tahir_tahir12-Apr-06 23:17
tahir_tahir12-Apr-06 23:17 
AnswerRe: converting client code from .cpp to .c Pin
kakan12-Apr-06 23:28
professionalkakan12-Apr-06 23:28 
GeneralRe: converting client code from .cpp to .c Pin
toxcct12-Apr-06 23:30
toxcct12-Apr-06 23:30 
GeneralRe: converting client code from .cpp to .c Pin
kakan12-Apr-06 23:32
professionalkakan12-Apr-06 23:32 

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.