Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

Home » Classic Visual Basic (VB 6 or earlier) » API » sector copy


sector copyExpand / Collapse
Author
Message
Posted 5/1/2009 7:14:49 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/10/2009 8:57:40 AM
Posts: 7, Visits: 18
Hi, I wanted to know, is it possible to copy sector by sector instead of file copy in VB? Is there certain windows function for that? Please help
Shree
Post #27610
Posted 5/2/2009 3:32:32 PM
Forum Guru

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru

Group: Forum Members
Last Login: 7/23/2010 8:17:22 PM
Posts: 169, Visits: 778
Yes it is possible but not via the API. You would have to do this yourself via the open command. (Open yourfile for input as #FileNumber) then to output...(Open NewFile for output as #DifferentFileNumber). check out the freefile function while your are at it.

Good Luck

Post #27614
Posted 5/2/2009 6:20:05 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/10/2009 8:57:40 AM
Posts: 7, Visits: 18
Thanks. I am not very familiar with the file handling operator.Actually, I want to read and copy the hard disk by sector. I am trying to use this function.
DrvHndl=CreateFile ("\\.\C:", GENERIC_READ + GENERIC_WRITE, FILE_SHARE_READ + FILE_SHARE_WRITE, lpSecurityAttributes, OPEN_EXISTING, ByVal FILE_FLAG_NO_BUFFERING, 0&). Does this function helps to read and copy the hard disk. I don't have much idea about these function. Please help....
Post #27616
Posted 5/3/2009 4:47:01 AM
Forum Guru

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru

Group: Forum Members
Last Login: 7/23/2010 8:17:22 PM
Posts: 169, Visits: 778
Whoa...

Disk Devices

Windows NT: You can use the CreateFile function to open a disk drive or a partition on a disk drive. The function returns a handle to the disk device; that handle can be used with the DeviceIOControl function. The following requirements must be met in order for such a call to succeed:

  • The caller must have administrative privileges for the operation to succeed on a hard disk drive.
  • The lpFileName string should be of the form \\.\PHYSICALDRIVEx to open the hard disk x. Hard disk numbers start at zero. For example:

StringMeaning
\\.\PHYSICALDRIVE2Obtains a handle to the third physical drive on the user's computer.

  • The lpFileName string should be \\.\x: to open a floppy drive x or a partition x on a hard disk. For example:

StringMeaning
\\.\A:Obtains a handle to drive A on the user's computer.
\\.\C:Obtains a handle to drive C on the user's computer.

Note that all I/O buffers must be sector aligned (aligned on addresses in memory that are integer multiples of the volume's sector size), even if the disk device is opened without the FILE_FLAG_NO_BUFFERING flag.

Windows 95: This technique does not work for opening a logical drive. In Windows 95, specifying a string in this form causes CreateFile to return an error.

  • The dwCreationDisposition parameter must have the OPEN_EXISTING value.
  • When opening a floppy disk or a partition on a hard disk, you must set the FILE_SHARE_WRITE flag in the dwShareMode parameter.

You are going to have to do a whole lot more work if you really want to do this. Start with the GetDiskFreeSpace API.

 

Good Luck

Post #27618
Posted 5/6/2009 7:27:21 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/10/2009 8:57:40 AM
Posts: 7, Visits: 18
Yes, I have already done those disk analysis part. I, now wanted to read the hard disk by sector and copy it. Can you help me out with some of the examples code.. Thanks
Post #27636
Posted 5/7/2009 12:59:48 AM
Forum Guru

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru

Group: Forum Members
Last Login: 7/23/2010 8:17:22 PM
Posts: 169, Visits: 778
With code... no as I have destroyed my fair share of hard drives and that I have never tried this method before but I can say that when you read from the disk, your buffer size needs to be the size of the sector. I think this is one of those things that I think you will have to do yourself by trial and error.

 

Good Luck

 

Post #27639
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Admin, Mod

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 7:01pm