WriteSectorW2K

This function writes a sector on a logical hard disk drive using a preloaded buffer. Works with Windows NT, Windows 2000 and Windows XP.

long _stdcall WriteSectorW2K(LPSTR sDrive, double LowPos, double HighPos, WORD Count, LPSTR Buffer, DWORD BufferSize);

Parameters

sDrive: The string containing the drive name. Use \\.\A: to access drive A, \\.\C: to access drive C and so on.
LowPos: A double carrying the low position of the address of the sector.
HighPos: A double carrying the high position of the address of the sector.
Count: Ignored, should be set to 1.
Buffer: A string preloaded with the data that will be written onto the disk. Should have BufferSize length.
Buffersize: Indicates the length of buffer.

To obtain the physical address of a sector use the formula Address=(NumberOfSector-1)*SectorSize where NumberOfSector is a 1-based count and SectorSize the size of the sector (512, 2048, etc). Then load the LowPos as unsigned long and HighPos as unsigned long, using the formula: Address=2^32*HighPos+LowPos. For up to 2GB HighPos should be equal to 0.

Back.