Sign in to follow this  
Followers 0
Triton

Possible Problem with DriveStatus()

4 posts in this topic

Heres the code:

Dim $RAMDRIVE = EnvGet("RamDrv")

$CHECKDRV = DriveStatus($RAMDRIVE & "\")
   MsgBox(0, "CHECKDRV", $CHECKDRV)
   If $CHECKDRV = "INVALID" Or $CHECKDRV = "NOTREADY" Or $CHECKDRV = "UNKNOWN" Then
      MsgBox(0, "ERROR", "RamDrv does not exist!")
      Exit
   EndIf

What happens is this:

$RAMDRIVE is set to an empty string because RamDrv variable does not exist and then DriveStatus($RAMDRIVE & "\") returns a "READY" status to and empty string and a \

Why would it return this value?


Triton

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Because \ = C:\, most likely. Open a command window and type cd \ and you'll be moved to C:\. The API behind the scenes could also be using this logic.

Edit: Technically, typing \ means to go to the root drive/directory (/ in *nix). In most installations of Windows, this will probably be the C: drive.

Edited by Valik

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

so, why not throw a drive get type in there?

Dim $RAMDRIVE = EnvGet("RamDrv")

$CHECKDRV = DriveStatus($RAMDRIVE & "\")
if DriveGetType($checkdrv) <> "RamDisk" then
   msgbox(0, "Error", "RamDisk not found"
   Exit; or something else
endif

  MsgBox(0, "CHECKDRV", $CHECKDRV)
  If $CHECKDRV = "INVALID" Or $CHECKDRV = "NOTREADY" Or $CHECKDRV = "UNKNOWN" Then
     MsgBox(0, "ERROR", "RamDrv does not exist!")
     Exit
  EndIf
Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

Because \ = C:\, most likely.  Open a command window and type cd \ and you'll be moved to C:\.  The API behind the scenes could also be using this logic.

Edit: Technically, typing \ means to go to the root drive/directory (/ in *nix).  In most installations of Windows, this will probably be the C: drive.

I'm at work now.

I did some small tests.

1.

- I opened a Run box

- entered: \

- pressed enter

Result: Windows Explorer opened my home directory. In my case H:

2.

- I opened a command box

- made C:\WINNT the current dir

- entered: cd \

- pressed enter

Result: current dir is set to C:

(Same thing with cd\ )

3.

- I opened a command box

- made H:\scripts the current dir

- entered: cd \

- pressed enter

Result: current dir is set to H:

(Same thing with cd\ )

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0