| | | Forum 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 |
| | | | Forum 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 |
| | | | Forum 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.... |
| | | | Forum 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:
| String | Meaning |
|---|
| \\.\PHYSICALDRIVE2 | Obtains 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:
| String | Meaning |
|---|
| \\.\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 |
| | | | Forum 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 |
| | | | Forum 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 |
| |
|
|