Drive Status

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Turner

    #1

    Drive Status

    Hi all,
    Is there a way in VB or via an API to get the status of a drive?
    I would like to write something along the lines of:

    If DriveState("C") = WRITE Then
    ' drive active, so show "WAIT" form
    frmPleaseWait.S how
    endIf

    ' wait for C to stop writing
    Do
    do Events
    Loop While DriveState("C") = WRITE

    ' unload the WAIT form
    UnLoad frmPleaseWait

    Any ideas or alternatives?

    TIA
    GST


  • Raoul Watson

    #2
    Re: Drive Status


    "Geoff Turner" <g.s.turner@rl. ac.uk> wrote in message
    news:c27fm4$j1q @newton.cc.rl.a c.uk...[color=blue]
    > Hi all,
    > Is there a way in VB or via an API to get the status of a drive?
    > I would like to write something along the lines of:
    >
    > If DriveState("C") = WRITE Then
    > ' drive active, so show "WAIT" form
    > frmPleaseWait.S how
    > endIf
    >
    > ' wait for C to stop writing
    > Do
    > do Events
    > Loop While DriveState("C") = WRITE
    >
    > ' unload the WAIT form
    > UnLoad frmPleaseWait
    >
    > Any ideas or alternatives?
    >
    > TIA
    > GST
    >[/color]

    Geoff.. this maybe a silly question but do you mind elaborating what you're
    trying to do (for what purpose). I use to write low level INT13 routines in
    assembly (for drive access) but with nowadays OS's, the hard drive is really
    "never" busy, i.e. a write request is almost always successful (even when
    the drive is busy, it goes into a cache / queue). OS's such as NT/2000, are
    not happy when an application tries to address hardware directly. But
    perhaps if you can explain what the purpose is, there might be an
    alternative.

    For example, if you are writing a large file, you may display a progress
    bar (and not really be concerned whether or not the drive is "physically "
    writing).


    Comment

    • Geoff Turner

      #3
      Re: Drive Status


      "Raoul Watson" <WatsonR@Intell igenCIA.com> wrote in message
      news:yVc2c.1631 8$YN5.15876@nwr dny03.gnilink.n et...[color=blue]
      >
      > "Geoff Turner" <g.s.turner@rl. ac.uk> wrote in message
      > news:c27fm4$j1q @newton.cc.rl.a c.uk...[color=green]
      > > Hi all,
      > > Is there a way in VB or via an API to get the status of a drive?
      > > I would like to write something along the lines of:
      > >
      > > If DriveState("C") = WRITE Then
      > > ' drive active, so show "WAIT" form
      > > frmPleaseWait.S how
      > > endIf
      > >
      > > ' wait for C to stop writing
      > > Do
      > > do Events
      > > Loop While DriveState("C") = WRITE
      > >
      > > ' unload the WAIT form
      > > UnLoad frmPleaseWait
      > >
      > > Any ideas or alternatives?
      > >
      > > TIA
      > > GST
      > >[/color]
      >
      > Geoff.. this maybe a silly question but do you mind elaborating what[/color]
      you're[color=blue]
      > trying to do (for what purpose). I use to write low level INT13 routines[/color]
      in[color=blue]
      > assembly (for drive access) but with nowadays OS's, the hard drive is[/color]
      really[color=blue]
      > "never" busy, i.e. a write request is almost always successful (even when
      > the drive is busy, it goes into a cache / queue). OS's such as NT/2000,[/color]
      are[color=blue]
      > not happy when an application tries to address hardware directly. But
      > perhaps if you can explain what the purpose is, there might be an
      > alternative.
      >
      > For example, if you are writing a large file, you may display a progress
      > bar (and not really be concerned whether or not the drive is "physically "
      > writing).
      >
      >[/color]

      I have some large files that get processed then saved to disc ( or CD ).
      Although the program has finished processing the files, and the cursor
      changes back to default icon, the disc is still writing data. I want a
      'window'
      to jump up telling the user to wait before removing the disc or exiting the
      program. ( You can make programs idiot proof, but not user proof. )

      GST


      Comment

      • J French

        #4
        Re: Drive Status

        On Mon, 8 Mar 2004 12:48:57 -0000, "Geoff Turner"
        <g.s.turner@rl. ac.uk> wrote:

        <snip>
        [color=blue]
        >
        >I have some large files that get processed then saved to disc ( or CD ).
        >Although the program has finished processing the files, and the cursor
        >changes back to default icon, the disc is still writing data. I want a
        >'window'
        >to jump up telling the user to wait before removing the disc or exiting the
        >program. ( You can make programs idiot proof, but not user proof. )[/color]

        You are onto a losing wicket there (in both cases)

        Hardware tells lies - and says that stuff is written, when it is just
        beginning to think about writing it

        Users need training

        DeviceIoControl and IOCTL_STORAGE_E JECT_MEDIA
        might help a bit

        Comment

        • Raoul Watson

          #5
          Re: Drive Status


          "Geoff Turner" <g.s.turner@rl. ac.uk> wrote in message
          news:c2hq3q$kda @newton.cc.rl.a c.uk...[color=blue]
          >
          > "Raoul Watson" <WatsonR@Intell igenCIA.com> wrote in message
          > news:yVc2c.1631 8$YN5.15876@nwr dny03.gnilink.n et...[color=green]
          > >
          > > "Geoff Turner" <g.s.turner@rl. ac.uk> wrote in message
          > > news:c27fm4$j1q @newton.cc.rl.a c.uk...[color=darkred]
          > > > Hi all,
          > > > Is there a way in VB or via an API to get the status of a drive?
          > > > I would like to write something along the lines of:
          > > >
          > > > If DriveState("C") = WRITE Then
          > > > ' drive active, so show "WAIT" form
          > > > frmPleaseWait.S how
          > > > endIf
          > > >
          > > > ' wait for C to stop writing
          > > > Do
          > > > do Events
          > > > Loop While DriveState("C") = WRITE
          > > >
          > > > ' unload the WAIT form
          > > > UnLoad frmPleaseWait
          > > >
          > > > Any ideas or alternatives?
          > > >
          > > > TIA
          > > > GST
          > > >[/color]
          > >
          > > Geoff.. this maybe a silly question but do you mind elaborating what[/color]
          > you're[color=green]
          > > trying to do (for what purpose). I use to write low level INT13 routines[/color]
          > in[color=green]
          > > assembly (for drive access) but with nowadays OS's, the hard drive is[/color]
          > really[color=green]
          > > "never" busy, i.e. a write request is almost always successful (even[/color][/color]
          when[color=blue][color=green]
          > > the drive is busy, it goes into a cache / queue). OS's such as NT/2000,[/color]
          > are[color=green]
          > > not happy when an application tries to address hardware directly. But
          > > perhaps if you can explain what the purpose is, there might be an
          > > alternative.
          > >
          > > For example, if you are writing a large file, you may display a[/color][/color]
          progress[color=blue][color=green]
          > > bar (and not really be concerned whether or not the drive is[/color][/color]
          "physically "[color=blue][color=green]
          > > writing).
          > >
          > >[/color]
          >
          > I have some large files that get processed then saved to disc ( or CD ).
          > Although the program has finished processing the files, and the cursor
          > changes back to default icon, the disc is still writing data. I want a
          > 'window'
          > to jump up telling the user to wait before removing the disc or exiting[/color]
          the[color=blue]
          > program. ( You can make programs idiot proof, but not user proof. )
          >
          > GST
          >[/color]

          That's a tough one (simply because of the write-ahead cache and buffers I
          mentioned). You did not specify what method you use to write this file (also
          whether you are using database, rdo, etc.).

          If you are using an OPEN statement, you can try using the RESET command (use
          Data1.refresh or movelast followed by movefirst on a dataset). This forces
          the file buffer to be flushed. The only problem is that most commands are
          executed asynchronously, so you get control in the program before the
          statement has completed the task (you may need to put a delay).

          You may think of using a dialog box after the writing. This accomplishes two
          goals: Since the user must respond, it buys you time to wait for the drive
          to wind down and for the flushed data to be written. Second, you may want to
          inform the user to wait until disk activity light is out prior to
          proceeding.


          Comment

          • Randy Birch

            #6
            Re: Drive Status

            No idea if this is viable, since you won't know when the system has finished
            writing the files, but you may be able to lock the drive shut (if running
            NT4 or later) using http://vbnet.mvps.org/code/disk/deviolock.htm

            --

            Randy Birch
            MVP Visual Basic

            Please respond only to the newsgroups so all can benefit.


            "Geoff Turner" <g.s.turner@rl. ac.uk> wrote in message
            news:c2hq3q$kda @newton.cc.rl.a c.uk...
            :
            : "Raoul Watson" <WatsonR@Intell igenCIA.com> wrote in message
            : news:yVc2c.1631 8$YN5.15876@nwr dny03.gnilink.n et...
            : >
            : > "Geoff Turner" <g.s.turner@rl. ac.uk> wrote in message
            : > news:c27fm4$j1q @newton.cc.rl.a c.uk...
            : > > Hi all,
            : > > Is there a way in VB or via an API to get the status of a drive?
            : > > I would like to write something along the lines of:
            : > >
            : > > If DriveState("C") = WRITE Then
            : > > ' drive active, so show "WAIT" form
            : > > frmPleaseWait.S how
            : > > endIf
            : > >
            : > > ' wait for C to stop writing
            : > > Do
            : > > do Events
            : > > Loop While DriveState("C") = WRITE
            : > >
            : > > ' unload the WAIT form
            : > > UnLoad frmPleaseWait
            : > >
            : > > Any ideas or alternatives?
            : > >
            : > > TIA
            : > > GST
            : > >
            : >
            : > Geoff.. this maybe a silly question but do you mind elaborating what
            : you're
            : > trying to do (for what purpose). I use to write low level INT13 routines
            : in
            : > assembly (for drive access) but with nowadays OS's, the hard drive is
            : really
            : > "never" busy, i.e. a write request is almost always successful (even
            when
            : > the drive is busy, it goes into a cache / queue). OS's such as NT/2000,
            : are
            : > not happy when an application tries to address hardware directly. But
            : > perhaps if you can explain what the purpose is, there might be an
            : > alternative.
            : >
            : > For example, if you are writing a large file, you may display a
            progress
            : > bar (and not really be concerned whether or not the drive is
            "physically "
            : > writing).
            : >
            : >
            :
            : I have some large files that get processed then saved to disc ( or CD ).
            : Although the program has finished processing the files, and the cursor
            : changes back to default icon, the disc is still writing data. I want a
            : 'window'
            : to jump up telling the user to wait before removing the disc or exiting
            the
            : program. ( You can make programs idiot proof, but not user proof. )
            :
            : GST
            :
            :


            Comment

            • Geoff Turner

              #7
              Re: Drive Status

              "Randy Birch" <rgb_removethis @mvps.org> wrote in message
              news:cUa3c.1607 32$ah.21828@twi ster01.bloor.is .net.cable.roge rs.com...[color=blue]
              > No idea if this is viable, since you won't know when the system has[/color]
              finished[color=blue]
              > writing the files, but you may be able to lock the drive shut (if running
              > NT4 or later) using http://vbnet.mvps.org/code/disk/deviolock.htm
              >
              > --
              >
              > Randy Birch
              > MVP Visual Basic
              > http://vbnet.mvps.org/
              > Please respond only to the newsgroups so all can benefit.
              >
              >
              > "Geoff Turner" <g.s.turner@rl. ac.uk> wrote in message
              > news:c2hq3q$kda @newton.cc.rl.a c.uk...
              > :
              > : "Raoul Watson" <WatsonR@Intell igenCIA.com> wrote in message
              > : news:yVc2c.1631 8$YN5.15876@nwr dny03.gnilink.n et...
              > : >
              > : > "Geoff Turner" <g.s.turner@rl. ac.uk> wrote in message
              > : > news:c27fm4$j1q @newton.cc.rl.a c.uk...
              > : > > Hi all,
              > : > > Is there a way in VB or via an API to get the status of a drive?
              > : > > I would like to write something along the lines of:
              > : > >
              > : > > If DriveState("C") = WRITE Then
              > : > > ' drive active, so show "WAIT" form
              > : > > frmPleaseWait.S how
              > : > > endIf
              > : > >
              > : > > ' wait for C to stop writing
              > : > > Do
              > : > > do Events
              > : > > Loop While DriveState("C") = WRITE
              > : > >
              > : > > ' unload the WAIT form
              > : > > UnLoad frmPleaseWait
              > : > >
              > : > > Any ideas or alternatives?
              > : > >
              > : > > TIA
              > : > > GST
              > : > >
              > : >
              > : > Geoff.. this maybe a silly question but do you mind elaborating what
              > : you're
              > : > trying to do (for what purpose). I use to write low level INT13[/color]
              routines[color=blue]
              > : in
              > : > assembly (for drive access) but with nowadays OS's, the hard drive is
              > : really
              > : > "never" busy, i.e. a write request is almost always successful (even
              > when
              > : > the drive is busy, it goes into a cache / queue). OS's such as[/color]
              NT/2000,[color=blue]
              > : are
              > : > not happy when an application tries to address hardware directly. But
              > : > perhaps if you can explain what the purpose is, there might be an
              > : > alternative.
              > : >
              > : > For example, if you are writing a large file, you may display a
              > progress
              > : > bar (and not really be concerned whether or not the drive is
              > "physically "
              > : > writing).
              > : >
              > : >
              > :
              > : I have some large files that get processed then saved to disc ( or CD ).
              > : Although the program has finished processing the files, and the cursor
              > : changes back to default icon, the disc is still writing data. I want a
              > : 'window'
              > : to jump up telling the user to wait before removing the disc or exiting
              > the
              > : program. ( You can make programs idiot proof, but not user proof. )
              > :
              > : GST
              > :
              > :[/color]

              Randy:
              Had a look at the suggetsed site, but I am using Win98.

              Raoul:
              File is opened for Binary I/O. The number of bytes read/written
              also varies from file to file.
              A Diaglog box may be the quickest soulution for now.

              Geoff Turner.




              Comment

              Working...