[Question] for Read/Wirte disk with DeviceIoControl(...) ?

From: Frank (winsays_at_hotmail.com)
Date: 12/26/03

  • Next message: WahJava: "Re: Smart Card Programming"
    Date: Fri, 26 Dec 2003 13:55:40 +0800
    
    

    Hi,there

    How to retrieve the count of sectors succeeded written to/read from disk
    when use following methods under Win9x.
    ///////////////////////////////////////////////////////////////
    BOOL fSuccess;
    DIOC_REGISTERS reg;
    CONTROLBLOCK ControlBlock;
    DWORD cb;

    hDevice = CreateFile("\\\\.\\vwin32",
            GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
            (LPSECURITY_ATTRIBUTES) NULL, OPEN_EXISTING,
            FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL);

    ControlBlock.StartingSector = (DWORD)dwStartLogicalSector;
    ControlBlock.NumberOfSectors = (WORD)dwNumberOfSectors;
    ControlBlock.pBuffer = (DWORD)(BYTE*)psfBuffer;

    //------------------------------------
    // SI contains read/write mode flags
    // SI=0h for read and SI=1h for write
    // CX must be equal to ffffh for
    // int 21h's 7305h extention
    // DS:BX -> base addr of the
    // control block structure
    // DL must contain the drive number
    // (01h=A:, 02h=B: etc)
    //------------------------------------

      reg.reg_ESI = 0x01; // or 0x00 for read

      reg.reg_ECX = -1 ;
      reg.reg_EBX = (DWORD)(&ControlBlock);
      reg.reg_EDX = (DWORD)hDevice;
      reg.reg_EAX = 0x7305;

    fSuccess = DeviceIoControl (m_hDrv,
    CON_VWIN32_DIOC_DOS_DRIVEINFO,
    &(reg),
    sizeof (reg),
    &(reg),
    sizeof (reg),
    &cb,
    0);

    if (reg.reg_Flags & 0x0001) fSuccess = FALSE;

    //////////////////////////////////////////////////////////////

    --
    Frank F.Han
    +-----------------------------------------+
    |         winsays@:-)hotmail:-).com       |
    +-----------------------------------------+
    

  • Next message: WahJava: "Re: Smart Card Programming"