Thread: Mapping out a hard drive.

  1. #1
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342

    Question Mapping out a hard drive.

    This will probably be a unanswerd question becouse it's
    of the wall, But here goes..

    I want to make a simple program that makes a map of the hard drive that the program is on. It would write to a file with the results.

    Thanks, August.

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    What do you mean by map? occupied sectors? full folder map? few more details would help you get an answer.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Chief Code Coloniser!
    Join Date
    Apr 2005
    Posts
    121
    This will probably be a unanswerd question

    You're right when you consider you didn't actually ask one!

  4. #4
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Here is an example of what I mean:

    C:\Documents and Settings\Administrator\My Documents\file1.txt
    C:\Documents and Settings\Administrator\My Documents\file2.txt
    C:\Documents and Settings\Administrator\My Documents\file3.txt
    C:\Documents and settings\Administrator\Cookies\[email protected]
    It would write a path to every file and folder on the computer.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    FindFirstFile/FindNextFile

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Okay, you've told us what kind of program you want to write, but you still haven't asked us a question. We're not going to write your whole program for you. If you're having trouble getting started look up the Win32 functions given to you above.

  7. #7
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Do the "FindFirstFile/FindNextFile" work?
    My question is: how can I do what I want to do?

  8. #8
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    I mean, would the "FindFirstFile/FindNextFile" work for what I want to do?

  9. #9
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    how can I do what I want to do?
    Go to MSDN and learn how to use the functions suggested to you, write some code, and then come to us with any specific problems you have.

  10. #10
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Okay, why isn't this working?
    Code:
    FindFirstFile("*.*",NULL);
    The compiler didn't come up with any errors or warnings, but when I executed the app,
    A "Program error" dialog came up.

  11. #11
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    That's because the second parramater should be a pointer to a WIN32_FIND_DATA structure and you set it too NULL so when the function tried to save the file information you're program crashed.

    First declare a WIN32_FIND_DATA structure and then pass it's address to FindFirstFile and you should also save the Find handle.
    Code:
    WIN32_FIND_DATA wfd;
    HANDLE hFind;
    hFind=FindFirstFile("*.*", &wfd);
    Last edited by Quantum1024; 05-01-2005 at 11:36 AM.

  12. #12
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    I'm not sure of the exact reason for a "Program error" dialog, but this hardly looks like what you'd want to be doing. You're not collecting the return value (file handle), and you're not collecting any of the other information for the file - you're using the function improperly and this very well could be causing the problem.

  13. #13
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Okay, is there a way I can get it to write the First File Found to a MessageBox?

  14. #14
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Code:
    MessageBox(NULL, wfd.cFileName, NULL, MB_OK);
    assuming your WIN32_FIND_DATA structure is named wfd.

  15. #15
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Is there a way to do the same thing but with FindNextFile?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extracting data from a laptop hard drive
    By DavidP in forum Tech Board
    Replies: 6
    Last Post: 06-13-2009, 07:02 AM
  2. Detect SCSI Hard Drive Serial Number
    By mercury529 in forum Windows Programming
    Replies: 3
    Last Post: 10-17-2006, 06:23 PM
  3. Replies: 2
    Last Post: 07-06-2005, 07:11 PM
  4. Trinary Hard Drive
    By nickname_changed in forum Tech Board
    Replies: 14
    Last Post: 05-13-2005, 10:01 AM
  5. hard drive problems continually increasing
    By DavidP in forum Tech Board
    Replies: 5
    Last Post: 11-21-2002, 10:48 PM