Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. monitoring and selecting root directory and report changes in that directory

monitoring and selecting root directory and report changes in that directory

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    keerthikaaa
    wrote on last edited by
    #1

    hai to all i want to do an application so that i can select a directory and by monitoring the selected directory i need to report the changes made in that directory. For that i have used a browse button to select the directory and displayed the selected directory to be monitored in the edit box. for this i have written like this : 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); Next i need a list control for displaying the changed directory files with column path and size and date. here my problem is how can i map the column path,size,date of the directory files to the columns in the listcontrol. :)

    R D H 3 Replies Last reply
    0
    • K keerthikaaa

      hai to all i want to do an application so that i can select a directory and by monitoring the selected directory i need to report the changes made in that directory. For that i have used a browse button to select the directory and displayed the selected directory to be monitored in the edit box. for this i have written like this : 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); Next i need a list control for displaying the changed directory files with column path and size and date. here my problem is how can i map the column path,size,date of the directory files to the columns in the listcontrol. :)

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      Create a CListCtrl in your project, use InsertColumn to create the path, size and date columns, use SetItem/InsertItem to modify/add entries in the CListCtrl ~RaGE();

      1 Reply Last reply
      0
      • K keerthikaaa

        hai to all i want to do an application so that i can select a directory and by monitoring the selected directory i need to report the changes made in that directory. For that i have used a browse button to select the directory and displayed the selected directory to be monitored in the edit box. for this i have written like this : 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); Next i need a list control for displaying the changed directory files with column path and size and date. here my problem is how can i map the column path,size,date of the directory files to the columns in the listcontrol. :)

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Use ReadDirectoryChangesW() or FindFirstChangeNotification().


        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

        "There is no death, only a change of worlds." - Native American Proverb

        1 Reply Last reply
        0
        • K keerthikaaa

          hai to all i want to do an application so that i can select a directory and by monitoring the selected directory i need to report the changes made in that directory. For that i have used a browse button to select the directory and displayed the selected directory to be monitored in the edit box. for this i have written like this : 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); Next i need a list control for displaying the changed directory files with column path and size and date. here my problem is how can i map the column path,size,date of the directory files to the columns in the listcontrol. :)

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          Hi keerthikaaa maybe it is some helpful to you http://www.codeguru.com/Cpp/W-P/files/article.php/c4467[^]

          K 1 Reply Last reply
          0
          • H Hamid Taebi

            Hi keerthikaaa maybe it is some helpful to you http://www.codeguru.com/Cpp/W-P/files/article.php/c4467[^]

            K Offline
            K Offline
            keerthikaaa
            wrote on last edited by
            #5

            hai whitesky the link which u have send is helpful to me.Thanks alot. there is a small problem here.ihave a browse button through i will select the path of the directory to which i need to monitor. To get that one i have used a variable to store the path .Now iwant that variable to be placed in the place where a predefined path is mentioned. But when place that variable there a error message that:Undeclared Identifier is coming. what should i do to give the path which i want to moniter. :)

            D 1 Reply Last reply
            0
            • K keerthikaaa

              hai whitesky the link which u have send is helpful to me.Thanks alot. there is a small problem here.ihave a browse button through i will select the path of the directory to which i need to monitor. To get that one i have used a variable to store the path .Now iwant that variable to be placed in the place where a predefined path is mentioned. But when place that variable there a error message that:Undeclared Identifier is coming. what should i do to give the path which i want to moniter. :)

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              keerthikaaa wrote:

              what should i do to give the path which i want to moniter.

              Without seeing the relevant code snippet, it's impossible to say.


              "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

              "There is no death, only a change of worlds." - Native American Proverb

              K 1 Reply Last reply
              0
              • D David Crow

                keerthikaaa wrote:

                what should i do to give the path which i want to moniter.

                Without seeing the relevant code snippet, it's impossible to say.


                "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                "There is no death, only a change of worlds." - Native American Proverb

                K Offline
                K Offline
                keerthikaaa
                wrote on last edited by
                #7

                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 {

                D 1 Reply Last reply
                0
                • K keerthikaaa

                  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 {

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  keerthikaaa wrote:

                  _beginthread( ThreadRoute1, 0, 0 );

                  Why are you not using AfxBeginThread() here?

                  keerthikaaa wrote:

                  ...i have used it to create the directory in the thread .

                  Where?

                  keerthikaaa wrote:

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

                  What else would you expect?

                  keerthikaaa wrote:

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

                  What is the value of m_sResults?


                  "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                  "There is no death, only a change of worlds." - Native American Proverb

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups