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. WIN32_FIND_DATA help

WIN32_FIND_DATA help

Scheduled Pinned Locked Moved C / C++ / MFC
help
11 Posts 3 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.
  • R Ryan McDermott

    I want to use WIN32_FIND_DATA to try to find folders, on the system, that contain a certain string. How exactly would I do this. Source code would help :-D -Ryan M.

    J Offline
    J Offline
    Joe Woodbury
    wrote on last edited by
    #2

    http://www.codeproject.com/script/comments/forums.asp?msg=815254&forumid=1647&XtraIDs=1647&searchkw=woodbury&sd=2%2F23%2F2004&ed=5%2F23%2F2004#xx815254xx[^] Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

    R 1 Reply Last reply
    0
    • J Joe Woodbury

      http://www.codeproject.com/script/comments/forums.asp?msg=815254&forumid=1647&XtraIDs=1647&searchkw=woodbury&sd=2%2F23%2F2004&ed=5%2F23%2F2004#xx815254xx[^] Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

      R Offline
      R Offline
      Ryan McDermott
      wrote on last edited by
      #3

      I tried that a long time ago. It didnt work. I even used the correct includes. -Ryan M.

      J 1 Reply Last reply
      0
      • R Ryan McDermott

        I tried that a long time ago. It didnt work. I even used the correct includes. -Ryan M.

        J Offline
        J Offline
        Joe Woodbury
        wrote on last edited by
        #4

        Well, I assure you it works. I have a half dozen programs that use this code, with some minor modifications of course. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

        R 1 Reply Last reply
        0
        • J Joe Woodbury

          Well, I assure you it works. I have a half dozen programs that use this code, with some minor modifications of course. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

          R Offline
          R Offline
          Ryan McDermott
          wrote on last edited by
          #5

          sorry buddy but it doesnt seem to search for folders that "contain a certain string" and not only that it doesn't seem to go through sub folders. Also it doesnt find all the folders that contain the string. Just another thing to say it doesnt start from the top level directory, C:\ for instance. So dont go saying that yours works because it dont:mad: -Ryan M.

          J 1 Reply Last reply
          0
          • R Ryan McDermott

            sorry buddy but it doesnt seem to search for folders that "contain a certain string" and not only that it doesn't seem to go through sub folders. Also it doesnt find all the folders that contain the string. Just another thing to say it doesnt start from the top level directory, C:\ for instance. So dont go saying that yours works because it dont:mad: -Ryan M.

            J Offline
            J Offline
            Joe Woodbury
            wrote on last edited by
            #6

            It doesn't search for folders which contain part of a string, it recursively looks for folders which ARE a specified string starting from the current directory, which is what the original poster was looking for. I never said otherwise. It is your job to modify the source for your own use. If you modify the "else if" section in "walk" to the following: else if (!IsDots(findData.cFileName)) { ::SetCurrentDirectory(findData.cFileName); TCHAR path[260]; ::GetCurrentDirectory(sizeof(path) / sizeof(TCHAR), path); _tprintf(_T("Changing to: %s\n"), path); foundDir = Walk(pDirToFind, pFinalPath); ::SetCurrentDirectory(_T("..")); } Then add: ::SetCurrentDirectory(_T("\\"));in main() just after the first if() section, it will search the entire drive, displaying the directories recursed, until it finds the directory MATCHING that from the command line. If this doesn't work for you, you are compiling and/or running it incorrectly. You are also making no effort to determine why it isn't performing as you expected. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

            R 1 Reply Last reply
            0
            • J Joe Woodbury

              It doesn't search for folders which contain part of a string, it recursively looks for folders which ARE a specified string starting from the current directory, which is what the original poster was looking for. I never said otherwise. It is your job to modify the source for your own use. If you modify the "else if" section in "walk" to the following: else if (!IsDots(findData.cFileName)) { ::SetCurrentDirectory(findData.cFileName); TCHAR path[260]; ::GetCurrentDirectory(sizeof(path) / sizeof(TCHAR), path); _tprintf(_T("Changing to: %s\n"), path); foundDir = Walk(pDirToFind, pFinalPath); ::SetCurrentDirectory(_T("..")); } Then add: ::SetCurrentDirectory(_T("\\"));in main() just after the first if() section, it will search the entire drive, displaying the directories recursed, until it finds the directory MATCHING that from the command line. If this doesn't work for you, you are compiling and/or running it incorrectly. You are also making no effort to determine why it isn't performing as you expected. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

              R Offline
              R Offline
              Ryan McDermott
              wrote on last edited by
              #7

              thanks. I got it to work. sorry i got pissy. -Ryan M.

              1 Reply Last reply
              0
              • R Ryan McDermott

                I want to use WIN32_FIND_DATA to try to find folders, on the system, that contain a certain string. How exactly would I do this. Source code would help :-D -Ryan M.

                M Offline
                M Offline
                Michael Dunn
                wrote on last edited by
                #8

                What do you mean by "folders that contain a certain string"? Folders contain files, not strings. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- "That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."   -- Buffy

                R 1 Reply Last reply
                0
                • M Michael Dunn

                  What do you mean by "folders that contain a certain string"? Folders contain files, not strings. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- "That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."   -- Buffy

                  R Offline
                  R Offline
                  Ryan McDermott
                  wrote on last edited by
                  #9

                  uhh yeah they can. folder name like "Program Files" Okey. "Files" is a string geneous -Ryan M.

                  M 1 Reply Last reply
                  0
                  • R Ryan McDermott

                    uhh yeah they can. folder name like "Program Files" Okey. "Files" is a string geneous -Ryan M.

                    M Offline
                    M Offline
                    Michael Dunn
                    wrote on last edited by
                    #10

                    Heh, that would have almost been a good flame except you misspelled "genius". My apologies for trying to help you. I will not make that mistake again. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Pinky, are you pondering what I'm pondering? I think so Brain, but if we shaved our heads, we'd look like weasels!

                    R 1 Reply Last reply
                    0
                    • M Michael Dunn

                      Heh, that would have almost been a good flame except you misspelled "genius". My apologies for trying to help you. I will not make that mistake again. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Pinky, are you pondering what I'm pondering? I think so Brain, but if we shaved our heads, we'd look like weasels!

                      R Offline
                      R Offline
                      Ryan McDermott
                      wrote on last edited by
                      #11

                      I forgot to tell you i am stupid. sorry for getting angry. -Ryan M.

                      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